Hi,
I'm using ArcPro 3.1.3 with an Advanced Licence with the data stored in a postgresql database accessed via sde.
When adding a new feature to a point dataset I have an attribute rule to populate the ID field with the existing maximum id + 1. I want the code to dynamically retrieve the current layer being worked on.
This is the code that in theory should work:
var CurrentLayer = GetFeatureSetInfo($featureset).className;
var CurrentIdField = FeatureSetByName($datastore, CurrentLayer, ["mpd_id"], false);
var CurrentMaxId = Max(CurrentIdField, "mpd_id");
return CurrentMaxId + 1;
However, the rule will not validate in ArcPro & returns the 999999 error.
I've tested the value returned to 'CurrentLayer' by writing it to a separate text field, the value is: "geodatabase.gisdata.MPD_PIPE_CABLE_CROSSINGS".
If I delete line 1 above and substitute the actual dataset name for 'CurrentLayer' in line 2 as follows:
var CurrentIdField = FeatureSetByName($datastore, "geodatabase.gisdata.MPD_PIPE_CABLE_CROSSINGS", ["mpd_id"], false);
then the code validates and runs producing the expected result. However, ultimately I need to be able to dynamically reference several layers in order to find the max id and so don't want to hard code any dataset names.
Does anyone know why the value of the variable CurrentLayer not read by the FeatureSetByName funciton?
I wondering if it could be a text case issue, so created a copy of my postgresql layer using all lower case characters, however this made no difference & returned the same error.