Attribute Rules: error running NextSequenceValue

898
2
Jump to solution
05-27-2021 09:38 PM
Labels (2)
asiegel_AWWD
New Contributor II

I am trying to create an attribute rule for a point feature class (Manholes) in which I want a field (FacilityID) to populate based on the combination of intersection with a polygon grid (Quarter Section) and a Database Sequence. For example, if I create a new point feature in grid 564 and the point is the 55th point in grid 564, I want the attribute rule to populate the FacilityID field with 564-55. I also want this rule to work with any grid, each which has its own Database Sequence counting the number of points. Here is what I have so far:

asiegel_AWWD_0-1622176273607.png

This script fails with the following error:

asiegel_AWWD_1-1622176306764.png

However, the script works if I hardcode the Database Sequence string name into line 12:

asiegel_AWWD_2-1622176432658.png

Does anyone know what might be causing the inputSequenceName to fail when passed into the NextSequenceValue instead of the hard coded string? 

 

I'd appreciate any help you can provide since this is my first time diving into Attribute Rules with Arcade. Thanks!

 

0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

It's hard to copy code from screen grabs. In the future, please use the "Insert Code Sample" button in the comment window: Expand the toolbar, then click this button and chose Javascript as language.

JohannesLindner_0-1622460109513.png

 

 

// The error is in this line
var inputSequenceName = 'ManholeSequence' + Text(matchedZone)

// matchedZone is a feature set, not a field!
// Try this:
var inputSequenceName = 'ManholeSequence' + Text(matchedZone.GRID)

 


Have a great day!
Johannes

View solution in original post

2 Replies
JohannesLindner
MVP Frequent Contributor

It's hard to copy code from screen grabs. In the future, please use the "Insert Code Sample" button in the comment window: Expand the toolbar, then click this button and chose Javascript as language.

JohannesLindner_0-1622460109513.png

 

 

// The error is in this line
var inputSequenceName = 'ManholeSequence' + Text(matchedZone)

// matchedZone is a feature set, not a field!
// Try this:
var inputSequenceName = 'ManholeSequence' + Text(matchedZone.GRID)

 


Have a great day!
Johannes
asiegel_AWWD
New Contributor II

Johannes, 

Thank you so much for the reply! I appreciate you showing me how to insert the code sample. Thanks for clarifying matchedZone is a feature set. Using your revision, I got my attribute rule to work the way I want. The only thing I had to change was removing the inputSequenceName variable and directly including the 'ManholeSequence' + Text(matchedZone.GRID) in the NextSequenceValue function. When I passed in the variable, it threw a null return error. Anyways, it's working now, so thanks again for the help!

// Create reference to the Quarter Section layer in the map
var zones = FeatureSetByName($datastore,"QuarterSection",["GRID"],true)

// Get a feature set of zones that intersect the point
var intersectingZones = Intersects(zones, Geometry($feature))

// Select the first record in the feature set
var matchedZone = First(intersectingZones)

// Return the grid value of the selected zone with the sequence number
return IIf(IsEmpty(matchedZone), null, matchedZone.GRID + "-" + NextSequenceValue("ManholeSequence"+Text(matchedZone.GRID)))

 

0 Kudos