Auto populate Related table from Parent table using Arcade in AGOL?

8675
27
Jump to solution
12-22-2023 05:14 AM
Labels (2)
KGalluccio
Regular Contributor

Is is possible to auto populate fields in a related table from the selected record in the parent table using Arcade in AGOL? 

I have a AGOL web map that includes one hosted feature layer with a related table with a one to many relationship.  The number of features in the feature layer is static.  Using forms, the map allows the user to select a feature and edit it's attributes, including adding records to the related table.  

The work process is that the current attributes of the selected feature need to be added as a new record in the related table, and then updated with new information.

When the user selects a feature to edit, then clicks to add a record to the related table, I would like the fields to auto populated with the selected features attributes.  

Is this possible?

Tags (2)
0 Kudos
27 Replies
ChristopherCounsell
MVP Regular Contributor

I read this incorrectly as populating the parent from the related record update. The above is possible.

0 Kudos
cat206
by
Frequent Contributor

Hi, does anyone know if is this possible when you have more than one parent feature layer (points, line and polygon) feeding into one related table (inspection records)?

 

0 Kudos
AmyCleare
Emerging Contributor

Will this work to populate a new record of related table? This fieldmap was created from three feature classes related to a single table, then published as a referenced feature layer to AGOL. The field map users only edit the table with a new record. Can the functionality that allows for autopopulating for data from a feature with the FeatureSetbyName be used in the conditional expression on a field in a FieldMap form?questions for ESRI community.PNG

 

0 Kudos
Marisa_Kordecki
Regular Contributor

I'm hoping someone here might have an idea of a similar issue I am having. 

I am trying to populate my related table with a parent table field. I do not get any errors when I use the calculation in AGOL on the field, but as there is no undo I would really prefer to do the calculation in ArcPro. 

Using the exact same code that would work in AGOL in my calculate field in ArcPro, I get an error that they cannot find the related tables.

0 Kudos
Marisa_Kordecki
Regular Contributor

I do not know why this is incorrectly marked as a solution. 

AdamAull
Emerging Contributor

I have a very similar workflow that needs a solution in ArcGIS Online Arcade.

A map was created with feature service containing a feature layer and its related table. The feature layer and related table both have an address field. The address field in the feature layer is calculated based upon an Arcade expression. The address field in the related table needs to be calculated based upon the related record's feature.

The workflow has a user creating a new feature and the Arcade expression populates the feature's address field. The user then creates a record related to the new feature and enters attribute values. An Arcade expression needs to pull the address from the feature into the related table record.

I can't seem to get the provided solution to run. Anyone have additional ideas?

0 Kudos
ACharvin
Occasional Contributor

Just came across this exact scenario and this is what worked for me.

Also you do have to make editable forms on both your Parent Layer and the Relate Table.

Go to each field you want to get auto populated and use this code snippet on the "Calculated expression" Section at the bottom right corner. 

var parent = First(FeatureSetByRelationshipName($feature, "ParentLayerName"));

if (!IsEmpty(parent)) {
    return parent."FieldNameYouWantOnTheRelate"; //No double Quotes
}
return null;

 
If there is an option to do something like this : return parent[$currentFieldName];
Then we won't have to do this for each script I think there is no way currently to do this?

0 Kudos
AdamAull
Emerging Contributor

Great! I'll have to try this in my application as it still has yet to be solved.

0 Kudos