Passing variable value to NextSequenceValue?

467
1
Jump to solution
01-28-2022 10:10 AM
RexRobichaux
Occasional Contributor

Hello everyone, 

 

  We are currently working to migrate some versioned editors using SQL Server / replication and ArcGIS Desktop, to ArcGIS Pro and feature service. This group uses Attribute Assistant, so I'm working to migrate this functionality to Attribute Rules. So far everything is going pretty well. I have hit one snag though...

 

I'm trying to create an attribute rule that will: 

  • We've created a database sequence for each locality using the naming convention s+FIPS for each locality. For example s011 for a sequence for a FIPS code with 011.
  • Perform a spatial intersect (when user creates a new polygon) to return the locality that polygon is within's FIPS code. (working).
  • We then take the returned FIPS code and concatenate it with s+FIPS to match the applicable sequence ID / Name. 
  • Then, we want to pass the new Sequence ID variable value (for example s011) into the NextSequenceFunction to ultimately return the next sequence value for any locality. This ultimately will populate the SEQUENCE field in the feature class/table.

The issue I'm having is  general evaluation failure when trying to execute the rule upon an edit as formatted below. The expression validates and saves without issue however. I know everything up to and including line 24 is working as we get th expected "s011" value which should match the sequence name/ID.

 

RexRobichaux_0-1643393204190.png

// Value to copy from the intersected feature
var intersecting_field = "FIPS";
//Field rule is assigned to in the Attribute Rule
var feature_field = $feature.SEQUENCE;

// Create feature set to the intersecting class using the GDB Name
var intersecting_featset = FeatureSetByName($datastore, 'VA_COUNTY_BOUNDARY_STG', [intersecting_field], true);

var search_feature = $feature;

var intersected_feature = First(Intersects(intersecting_featset, search_feature));

// Check to make sure there was an intersected feature, if not, return the original value
if (intersected_feature == null)
{
    return $feature.FIPS;
}
// If the intersected feature is null, return the original value
if (IsEmpty(intersected_feature[intersecting_field]))
{
    return $feature.FIPS;
}

var sequenceID = 's'+intersected_feature[intersecting_field];

var id = NextSequenceValue(sequenceID);

return id

 

Apologies as I'm still somewhat new to Arcade- but it is not possible to pass a variable value into a function? We have around ~130 sequences based off of FIPS so listing them out individually would be...not ideal.

 

Thank you for any help or tips you can provide!

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
RexRobichaux
Occasional Contributor

Well...this was a classic case of user error. It helps if you create the database sequences in the correct database. Once I created the test sequences in the appropriate geodatabase...it worked like a charm. Thanks folks!

View solution in original post

0 Kudos
1 Reply
RexRobichaux
Occasional Contributor

Well...this was a classic case of user error. It helps if you create the database sequences in the correct database. Once I created the test sequences in the appropriate geodatabase...it worked like a charm. Thanks folks!

0 Kudos