Hi
i have a probleme in my attribute rule that is executed twice in my feature service
the code calculate an id that increment by +1
// get the feature with the highest id
var m = FeatureSetByName($datastore,'oncf.dgf.urb_projet', ['*']);
var s= filter(m, "code_urb like 'URB%'")
var max_feature = First(OrderBy(s, "code_urb DESC"))
// get the number of that id
var max_number = 0
if(max_feature != null) { // no features in featureset? -> this block is skipped and max_number is 0
var txt = Replace(max_feature.code_urb, "URB", "")
max_number = Number(txt)
}
// calculate and return the new id
return "URB" + Text(max_number + 1, "00000")
when i create record in arcgis pro through geodatabase evrything work perfectly, for each record i create the ID increment by +1, but when i edit the data through feature service in Arcgis Pro or with the Edit widget in web app builder its like the attribute rule is executing twice (URB00002, URB00004, URB00006....) +2 for each new record.
thanks for you help
Solved! Go to Solution.
I see that you already implemented the change requested by Mike but still get the same behavior as you illustrated on another post. My guess since you are using 10.7.1 it could be a bug that we fixed in the next releases.
Try the following script as a workaround
// get the feature with the highest id
var m = FeatureSetByName($datastore,'oncf.dgf.urb_projet', ['*']);
//remove $feature from the equation.
var oid = $feature.objectid
var s= filter(m, "code_urb like 'URB%' AND objectid <> " + oid)
var max_feature = First(OrderBy(s, "code_urb DESC"))
// get the number of that id
var max_number = 0
if(max_feature != null) { // no features in featureset? -> this block is skipped and max_number is 0
var txt = Replace(max_feature.code_urb, "URB", "")
max_number = Number(txt)
}
// calculate and return the new id
return "URB" + Text(max_number + 1, "00000")
ound
You need to check Exclude from exclude_from_client_evaluation. If you do not check this, the client, such as ArcGIS Pro, will run the rule and when the data is sent to the database, it will run the rule again.
I see that you already implemented the change requested by Mike but still get the same behavior as you illustrated on another post. My guess since you are using 10.7.1 it could be a bug that we fixed in the next releases.
Try the following script as a workaround
// get the feature with the highest id
var m = FeatureSetByName($datastore,'oncf.dgf.urb_projet', ['*']);
//remove $feature from the equation.
var oid = $feature.objectid
var s= filter(m, "code_urb like 'URB%' AND objectid <> " + oid)
var max_feature = First(OrderBy(s, "code_urb DESC"))
// get the number of that id
var max_number = 0
if(max_feature != null) { // no features in featureset? -> this block is skipped and max_number is 0
var txt = Replace(max_feature.code_urb, "URB", "")
max_number = Number(txt)
}
// calculate and return the new id
return "URB" + Text(max_number + 1, "00000")
ound
the modification in the arcade code you made worked perfectly.
we will update soon to Enterprise 10.9.1, i hope il will fixe the problem.
thanks you very much