Select to view content in your preferred language

Auto populate related table with parent feature attributes

557
3
09-16-2024 08:02 AM
LukeRoyle
Emerging Contributor

I am trying to populate the fields of my related table from the attributes of a feature class.

This would be in order to create workflow that retains previous data for the position within the table, before the feature class it updated. Ideally,  the user opens the form for the related table, that auto populates and captures the current data. Then they update the feature class, retaining the previous data in the table.

I am unable to achieve this currently. I tried to use 2. from this Common calculated expressions for ArcGIS Field Maps.

But can't get it to work.

The site is on a grid, so I first tried to auto populate the grid number from the polygon into the related table for management of data. I have put the following into the calculated expression of the table itself:

 

var parentgrid = FeatureSetByRelationshipName($feature, 'HSV_Record', ['GridSquare'], false)

var relatedgrid = First(parentgrid)

if (!IsEmpty(relatedgrid)) {
    return relatedgrid['GridSquare']
}
else {
    return null
}

 

Where am I going wrong?

Thanks.

More details attached.

 

 

 

 

0 Kudos
3 Replies
DougBrowning
MVP Esteemed Contributor

There used to be a bug with relationships that had a _ in the name.  I thought that got fixed though.  Can you somehow test it taking the _ out of the name?

Other option is to use FeatureSetbyName and then wrap a Filter around that.

Other idea is try Count(relatedgrid) > 0 instead as I am not sure it will count as empty.

LukeRoyle
Emerging Contributor

I renamed the relationship, but no luck.

FeatureSetByName seemed to work at first, but it only strangely gives out "Q324" for every polygon I create a record for, I imagine this is due to the relationship not being present? It would not work for other attributes.

LukeRoyle_0-1726735444465.png

 

How would I put the Count into my expression exactly? Tried but ran an error.

 

Thanks for the response.

0 Kudos
DougBrowning
MVP Esteemed Contributor

You have to wrap Filter() around the feature set to query out the one you want since that just lists all of them.

I have 32 different RelationshipByName and they all work but I know there has been many posts that it does not.

On the count I think if relategrid is empty then you try and do Forst() it may fail.  Not sure really.  Always good to use Console() to print out what it is getting.

May need to be 

relatedgrid = (Filter(FeatureSet(), the SQL query)

If Count(relatedgrid) > 0 {

            return First(relatedgrid).GridSquare

else

    return null