Select to view content in your preferred language

tested successfully in webmap but get error in attribute rules

849
2
Jump to solution
01-11-2021 03:45 PM
JuneAcosta
Frequent Contributor

This script runs successfully when I test in the webmap against the service- see the attached image.

2021-01-11_15-02-39.jpg

However, I get an error once I try to use in  attribute rules using ArcPro 2.7.x. I'm new to attribute rules, and will appreciate any help folks on this forum.

I have a liftstation featureclass with a related table for repeat inspections using collector. I need a rule that will populated the station name from the liftstation featureclass to a field in the related table.

I get the error "Invalid expression Error on line 6 General evaluation error" . It's failing at the line "{
output += related_row.STATIONNAME"}

Here's the code used in attribute rules.

//get the guid of the table feature being updated
var filter_query = "GlobalID = '" + $feature.LStationID +"'"

//find the lift station layer
//$datastore is the current geodatabase
//get the GlobalId and STATIONNAME field
var related_fs = FeatureSetByName($datastore, 'gisdmz.SDECB.wwLiftStation',['GlobalID','STATIONNAME'])

//get the guid of the table feature being updated
var filter_query = "GlobalID = '" + $feature.LStationID +"'"

//find the station by filtering on the Guid
var related_filter = Filter(related_fs, filter_query)

var output = ''
for (var related_row in related_filter){
output += related_row.STATIONNAME
}
return {
"result": output
}

 

 

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
HusseinNasser2
Esri Contributor

Hard to tell from the script whats going on, but I modified the script to be more readable and less error prune by using the inline sql semantics so it takes care things for us like adding single quotes or dates predicates

You get the error on that line because thats when Arcade actually executes the query filter, make sure that the stationId is actually a valid globalId.

//get the guid of the table feature being updated
var lstationId = $feature.LStationID;
var filter_query = "GlobalID = @lstationId";

//find the lift station layer
//$datastore is the current geodatabase
//get the GlobalId and STATIONNAME field
var related_fs = FeatureSetByName($datastore, 'gisdmz.SDECB.wwLiftStation',['GlobalID','STATIONNAME'])

//get the guid of the table feature being updated
var filter_query = "GlobalID = @lstationId";

//find the station by filtering on the Guid
var related_filter = Filter(related_fs, filter_query)

var output = ''
for (var related_row in related_filter)
    output += related_row.STATIONNAME


return {
"result": output
}

View solution in original post

2 Replies
HusseinNasser2
Esri Contributor

Hard to tell from the script whats going on, but I modified the script to be more readable and less error prune by using the inline sql semantics so it takes care things for us like adding single quotes or dates predicates

You get the error on that line because thats when Arcade actually executes the query filter, make sure that the stationId is actually a valid globalId.

//get the guid of the table feature being updated
var lstationId = $feature.LStationID;
var filter_query = "GlobalID = @lstationId";

//find the lift station layer
//$datastore is the current geodatabase
//get the GlobalId and STATIONNAME field
var related_fs = FeatureSetByName($datastore, 'gisdmz.SDECB.wwLiftStation',['GlobalID','STATIONNAME'])

//get the guid of the table feature being updated
var filter_query = "GlobalID = @lstationId";

//find the station by filtering on the Guid
var related_filter = Filter(related_fs, filter_query)

var output = ''
for (var related_row in related_filter)
    output += related_row.STATIONNAME


return {
"result": output
}
JuneAcosta
Frequent Contributor

Thank you. Now it validates in ArcGIS Pro- I also added a line to check for a valid value before populating the record. Now I will test that it works in the Collector app.

0 Kudos