Select to view content in your preferred language

Field Maps, FeatureSetByRelationshipName, Arcade, Related Tables

3461
23
08-16-2022 07:47 AM
by Anonymous User
Not applicable

Hello,  I am trying to populate a field (Site_ID) in a related table (campground_evaluations) using the arcade function FeatureSetByRelationshipName.  The related feature that I am trying to pull from is called MTH_Campgrounds.

In Field Maps I want to select a point (campground in this example case) and select the related table icon and enter data into the form I created for the table.  Hopefully, this code will reduce the potential for error while inputting data into the table's form.  The feature and table are related using Global IDs.  This is where I am, but I get a Execution Error:Cannot read properties of null (reading 'toString').

var related = FeatureSetByRelationshipName($feature,'MTH_Campgrounds', ["SITE_ID"], false)

var record = First(related)

if (IsEmpty(record)){

  return "No Record Found"

}

return record['SITE_ID']

 

Thanks in advance!

23 Replies
KatiePiper
New Contributor III

 

var parent_fs = FeatureSetByRelationshipName($feature, 'MTH_Campgrounds', ['SITE_ID'], true)


var parent = First(parent_fs)


if (!IsEmpty(parent)) {
    return parent['Serial_Num']
} else {
    return null
}

 

 

Hi Matthew, try this. I tried for so long a few weeks ago and eventually got this code to work with my dataset. I find that it helps to use the Global links to input the feature class and field and not just type it in. Hope it works for you. 

by Anonymous User
Not applicable

Thanks for your reply!!  The code still generated the error message though...  I am about to resort to just making a separate table created from the relates.

0 Kudos
KatiePiper
New Contributor III

Ah okay, I just realized I didn't change the "Serial_Num" to "SITE_ID" Not sure if you caught/changed that. 

0 Kudos
by Anonymous User
Not applicable

I did, catch that.. no go

0 Kudos
by Anonymous User
Not applicable

Does the table's (campground_evaluations) field (SITE_ID) that we are trying to populate from the related feature (MTH_CAMPGROUNDS) need to be identified as a variable?

0 Kudos
KatiePiper
New Contributor III

I don't think so because you are putting the arcade expression under that field on field maps. That is where you are putting it, correct?

0 Kudos
by Anonymous User
Not applicable

yes that is correct

0 Kudos
by Anonymous User
Not applicable

So I added brackets, and the test for this code worked!!  But, when I open the map in the mobile field maps app it says calculation failed....  any ideas?

 

Here is the code

var parent_fs = FeatureSetByRelationshipName($feature, ['MTH_Campgrounds'], ['SITE_ID'], true)

var parent = First(parent_fs)

if (!IsEmpty(parent)) {
return parent_fs['SITE_ID']
} else {
return null
}

 

 

 

 

0 Kudos
KatiePiper
New Contributor III

That was my trouble for days before I was able to get it to work. In the information I was reading.. it sounded like after $feature you had to put the relationship class name. I kept trying to do that but then randomly tried the parent class name and it worked. So I can only suggest trying different names that you used while creating the feature class?

 

https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-to-pass-a-value-from-parent-to/td-...

https://community.esri.com/t5/arcgis-field-maps-questions/automatically-populating-related-table-fie...