Hi Team,
I am using ArcGIS Pro V 3.0.3. I am planning to add an Attribute Rule on Feature Class - B to copy value from Field1 of Feature Class - A, based on value from Field2 of Feature Class B.
I would like to add Attribute Rule for Insert trigger only, however, by that time, Feature Class B's new feature may not have value for Field2. So, have to include Update trigger also.
In this scenario, how can we control execution of Attribute Rule only on update of Field2 value of Feature class B and not on any kind of Update.
Thanks in advance!
With Regards,
Vara Prasad
Solved! Go to Solution.
// Calculation Attribute Rule on Featureclass B
// Field1
// Triggers: Insert, Update
var field_2 = $feature.Field2
// if we're inserting a fetaure with an empty Field2
// or we're updating a feature without changing Field2,
// return the value that is already in Field1
if(($editcontext.editType == "INSERT" && field_2 == null) ||
($editcontext.editType == "UPDATE" && $originalfeature.Field2 == field_2)) {
return $feature.Field1
}
// load Featureclass A
var fc_a = FeaturesetByName($datastore, "FeatureclassA")
// get the related feature
var related_a = First(Filter(fc_a, "Field2 = @field_2"))
// return that feature's Field1 value or null if no feature was found
return IIf(related_a == null, null, related_a.Field1)
// Calculation Attribute Rule on Featureclass B
// Field1
// Triggers: Insert, Update
var field_2 = $feature.Field2
// if we're inserting a fetaure with an empty Field2
// or we're updating a feature without changing Field2,
// return the value that is already in Field1
if(($editcontext.editType == "INSERT" && field_2 == null) ||
($editcontext.editType == "UPDATE" && $originalfeature.Field2 == field_2)) {
return $feature.Field1
}
// load Featureclass A
var fc_a = FeaturesetByName($datastore, "FeatureclassA")
// get the related feature
var related_a = First(Filter(fc_a, "Field2 = @field_2"))
// return that feature's Field1 value or null if no feature was found
return IIf(related_a == null, null, related_a.Field1)
Hi @JohannesLindner ,
Thank you very much for the inputs. It is almost same as that of my code except using editcontext. I learnt a new point - editcontext from your post. Thank you.
FeatureclassByName- is not available it seems. "Verify" option is throwing error. I have used FeatureSetByName function. Apart from that rest of the code is working fine. Thank you very much.
With Regards,
Vara Prasad
FeatureclassByName- is not available
Oops, got confused with the terminology. Good catch, I edited my answer.