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

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
}