Select to view content in your preferred language

Autopopulate field in FM related table form from field in parent layer

278
4
Jump to solution
06-29-2025 09:37 PM
DanGruber
Regular Contributor

Hello, all,

I have a point layer ("Postfire_Planting_Data") that contains a field called Plot_ID and a related table ("Postfire_Monitoring_Data_Related") (1:M) that records updates to the original point. I'd like to auto-populate a Plot_ID field in the related table form using the Plot_ID from the parent layer. The layer and table are related via GlobalID (layer) to GUID (table). The ArcPro project GDB calls the relationship "Postfire_Planting_Data_Postfire_Monitoring_Data_Related". The layer, table, and relationship class were uploaded to AGOL, and I used FM Designer to create forms for the parent layer and the related table.

The Plot_ID field in the parent layer always is filled in. I want to pull that ID from the parent layer into every related table entry associated with a point in the parent layer.

I saw a number of variations of Arcade coding that supposedly would do this, but none have worked for me. Here's my last attempt, which tests in FM Designer to return "null" but on the FM app related table form says it can't calculate a value.

var parent_features = FeatureSetByRelationshipName ($feature, 'Postfire_Planting_Data_Postfire_Monitoring_Data_Related', ['Plot_ID']);

var parent_feature = First(parent_features);

if (!IsEmpty (parent_feature))  {return parent_feature ['Plot_ID']} else {return null}

Since the Plot_ID field in the parent layer always is filled in, I tried replacing the 2nd and 3rd Arcade lines above with just "return parent_features ['Plot_ID']", but that didn't work either.

Surely this is a common problem with an obvious solution. I just can't find one that works!

Any help would be appreciated.

Thank you,

Dan Gruber

 

0 Kudos
1 Solution

Accepted Solutions
NathanDavis
Occasional Contributor

We do something similar.  I looked at the related tables and calcs that we have in production, and here are my thoughts.

When the relationship class is created in Pro, it's automatically given a 'class name' and an 'origin name'. 

The 'class name' consists of the merged layer names, like you noted here:
- 'Postfire_Planting_Data_Postfire_Monitoring_Data_Related'

The 'origin name' consists of the original table.  For your data, I expect this may be:
- 'Postfire_Planting_Data'

I think that FeatureSetByRelationshipName looks at the second scenario - the 'origin name'; while FeatureSetByRelationshipClass looks at the 'class name'.

It appears that the relationship name, when published, is the 'origin name'.

I recommend looking at the table's rest service and confirming the name of the relationship.  The name of the relationship displayed in the rest service can be referenced by FeatureSetByRelationshipName.

Good luck!

View solution in original post

0 Kudos
4 Replies
NathanDavis
Occasional Contributor

We do something similar.  I looked at the related tables and calcs that we have in production, and here are my thoughts.

When the relationship class is created in Pro, it's automatically given a 'class name' and an 'origin name'. 

The 'class name' consists of the merged layer names, like you noted here:
- 'Postfire_Planting_Data_Postfire_Monitoring_Data_Related'

The 'origin name' consists of the original table.  For your data, I expect this may be:
- 'Postfire_Planting_Data'

I think that FeatureSetByRelationshipName looks at the second scenario - the 'origin name'; while FeatureSetByRelationshipClass looks at the 'class name'.

It appears that the relationship name, when published, is the 'origin name'.

I recommend looking at the table's rest service and confirming the name of the relationship.  The name of the relationship displayed in the rest service can be referenced by FeatureSetByRelationshipName.

Good luck!

0 Kudos
DanGruber
Regular Contributor

Thanks, I'll give that a try. What's the "rest service" for the table? Is it the detail you see when you View the URL?

Dan

0 Kudos
NathanDavis
Occasional Contributor

Yep - that's right.  Scroll down a bit and you should be able to see the relationships.

0 Kudos
DanGruber
Regular Contributor

When I did as you suggested, it works! Thanks very much.

Dan

0 Kudos