Survey123 add related record to existing feature

328
3
Jump to solution
02-24-2022 01:47 PM
DarrylKlassen1
Occasional Contributor
Hello,
I have an existing feature service that has spatial data (buildings) and an inspections table related to it. I want to collect inspections against them using Survey123. Basically I would like to have a dropdown of all the building names - which would then find the globalid of that building - and populate the foreign key of the inspections so the relationship remains valid. I don't know how to do this in Survey123. I am able to populate my dropdown based on my feature layer using this in the appearance column:
autocomplete search("name?url=https://services1.arcgis.com/1acZBnEF9zjV0l5X/arcgis/rest/services/Test/FeatureServer/0")

But how do I populate my Foreign Key within the Survey in the related table automatically based on the building selection?

Thanks

1 Solution

Accepted Solutions
DarrylKlassen1
Occasional Contributor

@IsmaelChiviteI accomplished this using a piece of javascript and this in the calculation field:

pulldata("@javascript","get_globalid.js", "findCode", 'https://services1.arcgis.com/1acZBnEF9zjV0l5X/arcgis/rest/services/Building_Data_Test3/FeatureServer/0', string(${NAME}), 'GlobalID')

Thanks for your suggestion!

View solution in original post

3 Replies
IsmaelChivite
Esri Notable Contributor

Have you considered using the Inbox for this?

Through the Inbox, you will be able to display (and filter) all buildings as a list and also as a map. Selecting a building from the list or map will open the survey for that building. Adding a new row into the buildings inspection repeat will automatically add your inspection as a related record.

DarrylKlassen1
Occasional Contributor

Thanks @IsmaelChivite for the quick response.   I have never tried the Inbox before.  I don't really want to have the user select the building spatially, just from a drop down.   Do you have a link to any examples of how this can be done using an existing feature service and related tables? 

DarrylKlassen1
Occasional Contributor

@IsmaelChiviteI accomplished this using a piece of javascript and this in the calculation field:

pulldata("@javascript","get_globalid.js", "findCode", 'https://services1.arcgis.com/1acZBnEF9zjV0l5X/arcgis/rest/services/Building_Data_Test3/FeatureServer/0', string(${NAME}), 'GlobalID')

Thanks for your suggestion!