Add Inspection/Related Record: Bring Value from Feature Class to Related Table? Arcade?

3036
14
Jump to solution
05-18-2022 08:27 AM
ArmstKP
Occasional Contributor III

When clicking the blue add button to add a related record/inspection, it brings the globalid/guid value forward into the related table, but what if I want the feature class park name value to populated the related table as well in the park_name field?

0 Kudos
2 Solutions

Accepted Solutions
by Anonymous User
Not applicable

Check out the second example in this blog post. It should be exactly what your looking for, just change the layer name and attribute name.

View solution in original post

0 Kudos
by Anonymous User
Not applicable

Just as a follow-up, we've identified two issues related to FeatureSetByRelationshipName.

1. If your relationship contains a "." in it, then the Android and iOS apps fail to successfully execute the expression. This also occurs in Pop-ups. This is under investigation but probably won't make the next release.

2. In the Arcade editor, if the related layer/table does not have any features it, when you attempt to test it or save an expression that used FeatureSetByRelationshipName the editor fails to execute the expression with "Execution Error:Cannot read properties of undefined (reading 'toString')". The reason it fails is due to how the Arcade Editor evaluates the expression when the foreign key field value is null. When Field Maps or Map Viewer launch the Arcade editor, they need to provide a sample feature to represent $feature. It will query to find the first feature in the layer/table and use that. If there are no features, it generates a sample feature using the default values of the field. In this specific case, if your related table has no features in it, this sample feature will likely have a null value for it's foreign key field. A simple workaround is in the Arcade Editor edit $feature using the > icon and then the pencil/edit icon and add any value to the foreign key field (it doesn't matter what). Then you should be able to test and save it. This is not planned to be fixed in the next release.

View solution in original post

14 Replies
MobiusSnake
MVP

Arcade should do it.  I've set up this kind of thing in Pro using GDB attribute rules but the same approach should work with a calculated expression in Field Maps.  Use the foreign key GUID to find the parent record with a feature set, get the first record of the feature set and pull the field you want off that feature.

0 Kudos
ArmstKP
Occasional Contributor III

@MobiusSnake  Could you give me a small example to go off of?

 

0 Kudos
by Anonymous User
Not applicable

Check out the second example in this blog post. It should be exactly what your looking for, just change the layer name and attribute name.

0 Kudos
ArmstKP
Occasional Contributor III

@Anonymous User  I used that code and it worked when I clicked the "Test" Button.  I saved it and then opened up Field Maps 22.2 and I get in red text, "Failed to calculate"

ArmstKP_0-1652894655773.png

 

0 Kudos
by Anonymous User
Not applicable

Are you using offline areas by any chance?

If you go to Profile->Troubleshooting->Logs do you see any messages with "Arcade" in them? The error is probably logged there.

0 Kudos
ArmstKP
Occasional Contributor III

We aren't using offline areas.

This looks to be the related error in the log:

ArmstKP_0-1652896910361.png

 

0 Kudos
by Anonymous User
Not applicable

In the expression did you change the relationship name? In my example it's "wHydrants", yours is probably different.

If you open the table JSON, you can find the relationship name.

Go to the child layer/table page and click view in the bottom right:

AaronPulver_0-1652897239288.png

Then in the upper left corner click json:

AaronPulver_2-1652897380502.png

 

Then look for the relationships property and the name property within that, copy that and use it in your expression.

AaronPulver_3-1652897429866.png

 

0 Kudos
ArmstKP
Occasional Contributor III

I did change the relationship name to my own.  I have come up with another solution (below) without dealing with FeatureSetByRelationshipName.  I see a lot of people are having the same issue.

 

var relate_guid = $feature["relfeatureglobalid"];
var featSet = FeatureSetByName($map,"Parks Mowing", ['Park_ID','globalid'], false);
for(var feat in featSet){
if(Lower(feat.globalid)==Lower(relate_guid)){
return feat.Park_ID;
}
}

Seems like I am having the same issue as this post:  https://community.esri.com/t5/arcgis-field-maps-questions/featuresetby-arcade-functions-supported-in...

DougBrowning
MVP Esteemed Contributor

Yes I have seen this as an issue before I use map and then the layer name, like you are, and it seems to work better.