I have an Attribute Rule set to trigger on Insert (using ArcGIS Pro 2.5.1). It takes the value of a field in a source layer and then adds it to the field in a target layer. It works so far that the target table gets updated. However, after insert the source field resets back to it's default of 0 (it's a number field).
When I deactive the rule the source layer gets updated normally.
Both layers are tables in a FGDB. The target table only has one row.
var fsTargetTable = First(FeatureSetByName($datastore, "Totals", ["globalid","gloves_xs"], false));
var glovecount = $feature.gloves_xs;
var totalglovecount = fsTargetTable.gloves_xs;
totalglovecount += glovecount;
var AddList = [];
AddList[0] = {
'globalid':fsTargetTable.globalid,
'attributes':{
'gloves_xs':totalglovecount
}
};
return {
'edit': [{
'className': 'Totals',
'updates': AddList
}]
}
Solved! Go to Solution.
Hello!
Hope I can help, the reason the value is getting set to 0 is because you haven't provided a result in the return payload. thus the default will be used..
If you want to preserve the field value you input just simply return it back as follows..
var fsTargetTable = First(FeatureSetByName($datastore, "Totals", ["globalid","gloves_xs"], false));
var glovecount = $feature.gloves_xs;
var totalglovecount = fsTargetTable.gloves_xs;
totalglovecount += glovecount;
var AddList = [];
AddList[0] = {
'globalid':fsTargetTable.globalid,
'attributes':{
'gloves_xs':totalglovecount
}
};
return {
'result': $feature.yoursourcefieldname,
'edit': [{
'className': 'Totals',
'updates': AddList
}]
}
Hello!
Hope I can help, the reason the value is getting set to 0 is because you haven't provided a result in the return payload. thus the default will be used..
If you want to preserve the field value you input just simply return it back as follows..
var fsTargetTable = First(FeatureSetByName($datastore, "Totals", ["globalid","gloves_xs"], false));
var glovecount = $feature.gloves_xs;
var totalglovecount = fsTargetTable.gloves_xs;
totalglovecount += glovecount;
var AddList = [];
AddList[0] = {
'globalid':fsTargetTable.globalid,
'attributes':{
'gloves_xs':totalglovecount
}
};
return {
'result': $feature.yoursourcefieldname,
'edit': [{
'className': 'Totals',
'updates': AddList
}]
}
Thanks for the reply! This was my issue and the rule works great now.