Select to view content in your preferred language

Arcade expression moved from AGOL to portal/enterprise

331
5
Jump to solution
08-06-2024 12:39 PM
Ona_Tim
Emerging Contributor

We have been migrating over from AGOL to enterprise.  In one of our field maps, when we try to add a new related record to the water meter related table the the parent meter id (meterno is its name in the feature class table) will not populate using the following arcade expression.  

Everything nlooks right but is there some difference in terms in portal vs online?

Thank you.

Tim

// Get the feature set for the related wMeters feature

// and return only FacilityID

var fset = FeatureSetByRelationshipName(
    $feature,
    '',
    ['MeterNo'],
    false
);

// Get the first water meter (should only be one)
var parentFeat = First(fset)

// If there was a meter, return its Facility ID,
// Otherwise, return null
if (!IsEmpty(parentFeat)) {
    return parentFeat['MeterNo']
} else {
    return null
}
0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

Not the table name, the relationship class. In the expression editor, you can look in the Profile Variables to find the related table:

jcarlson_0-1722986369276.png

Clicking on the related table will show you the correct text to put into the function. It may be the table name, but may not. You can see the relationship class name in the Feature Service definition on your server.

jcarlson_1-1722986426249.png

 

- Josh Carlson
Kendall County GIS

View solution in original post

0 Kudos
5 Replies
jcarlson
MVP Esteemed Contributor

There is definitely a difference between the two. AGOL always has the latest version of Arcade, but Portal's Arcade version is fixed. This means that improvements and functions you might have used in AGOL can stop working on an older version of the same tools.

I don't see anything particularly telling in your expression, but what's going on with the second parameter of your FeatureSetByRelationshipName function? Shouldn't the relationship class have a name?

- Josh Carlson
Kendall County GIS
0 Kudos
Ona_Tim
Emerging Contributor

This script was written by my predecessor so I am not sure why they did not include the name of the related table.  I did try including the related table name and still did not work.

0 Kudos
jcarlson
MVP Esteemed Contributor

Not the table name, the relationship class. In the expression editor, you can look in the Profile Variables to find the related table:

jcarlson_0-1722986369276.png

Clicking on the related table will show you the correct text to put into the function. It may be the table name, but may not. You can see the relationship class name in the Feature Service definition on your server.

jcarlson_1-1722986426249.png

 

- Josh Carlson
Kendall County GIS
0 Kudos
Ona_Tim
Emerging Contributor

Thank you!  This solved the problem.

0 Kudos
Ona_Tim
Emerging Contributor

Here is the correct code.

 

// Get the feature set for the related wMeters feature
// and return only FacilityID
 
var related = FeatureSetByRelationshipName($feature, "wMeter")
 
// Get the first water meter (should only be one)
var parentFeat = First(related)

// If there was a meter, return its Facility ID,
// Otherwise, return null
if (!IsEmpty(parentFeat)) {
    return parentFeat['meterno']
} else {
    return null
}
0 Kudos