Select to view content in your preferred language

Repeat Fields Not Pre-Populating with Related Data

1052
7
06-14-2022 05:37 PM
cphelan7
New Contributor II

I have a dataset of forestry plots where field crews collect data on every tree that falls within a certain radius of that plot (one plot, many trees). I am attempting to do the common task of creating a survey where a field technician can select a plot and then page through each tree (repeats) to edit or add data as necessary. Despite excessive troubleshooting, I cannot get the repeat fields in the Survey123 App to pre-populate with the old data from a related table. I believe I am caught up on something very small or simple, but can't for the life of me figure it out. For background, I have conducted the following (ArcGIS Pro 2.9.2 and AGOL):

- created a GlobalID field for the plots and a GUID field for the trees

- joined the plots and trees on a common plot name field and filled the trees' GUID field with the plots' GlobalID

- removed join and used Create Relationship Class to create a one to many relate (GlobalID and GUID fields as primary and foreign keys respectively)

- Published a Web Layer (hosted feature service) with all editing enabled and syncing enabled in the Configuration tab

- Used Survey123 Connect to create a new survey from the feature service, XLSForm auto-generated the repeat based on the related Tree table, and I added "allowUpdates=true query" to the esri bind parameters column.

-Turned on Inbox, turned on Enable Sync, and successfully published

- On Survey123 App downloaded the survey and refreshed to load all the plots

- ISSUE: Select a plot from the list (or on the map) and select edit. Survey opens and the repeat is visible but NO data is pre-populated

I greatly appreciate any help!

0 Kudos
7 Replies
DougBrowning
MVP Esteemed Contributor

I use this a lot in my project - I have 20 relates in my service so I will try to help. 

You did not say what field names you used.  123 needs the repeat key to be parentglobalid.  I am pretty sure you cannot just pick some other field.  The relationship class may have to be a special name also not positive since I always use the built in one and add more if I need them.  The naming can be weird but it tends to have the service id in it.

DougBrowning_1-1655299724665.png

Also note there is a bug where the labels are not being added.

You can have additional relates also but it needs the standard ones to work right.  It will not just use what you have.

I am assuming you are doing all this because you have an existing layer?  You have a few options I think.  First make a copy of the survey and publish it as a new form.  Download the GDB from AGOL and look at the relates and field names.  Add relates in your service to match.

Or if you can, do what I do.  Publish the form, download the GDB, then add any additional relates you want.  Publish this GDB as a new service.  Point the form to this new service.  You could then append in all your historical data.  You can have more relates but it must have those default ones.

Hope that all makes sense and helps.

cphelan7
New Contributor II

Thank you @DougBrowning . You have given me a few routes to try, and I will report back on success. I am not concerned about labels at the moment, so the bug shouldn't be an issue. I have attached a few screenshots for your consideration.

Yes, you are correct that I have an existing points layer for the Plots (origin) and then a standalone table of Trees (destination). I used the Generate GlobalID tool to create the GlobalID field for the Plots and then added a GUID type field for the trees which I named parentglobalID. I filled the parentglobalID field in Trees with corresponding values from the Plots' GlobalID field, and then used these two fields when I created the relate.

Do you mind clarifying what you meant by 123 needs the repeat key to be parentglobalid? I have attached a screenshot of the repeat wording in the XLSForm, referencing the child/related table. Is that not correct?

Thank you!

0 Kudos
DougBrowning
MVP Esteemed Contributor

You need a GUID field in the repeat called parentglobalid (note it is case sensitive but you posted ID in caps so fix that)  since that is what 123 needs to populate for the key.  You cannot just make any GUID field it has to be that name.

Also you have a reserved work in your screen shot which will cause issue.  The little green box it telling you its reserved and cannot be used.  Make sure to fix that.

DougBrowning_0-1655313275046.png

Again the best way to see how it works it to copy the form, publish it, download the GDB, then match your service to that.  You have to do it the way 123 wants.  I do it the easy way and just use the 123 GDB as my base.

Hope that helps.

cphelan7
New Contributor II

Thanks again for time @DougBrowning 

I am now a bit more confused. I don't follow how to complete the method you recommend here:

Or if you can, do what I do.  Publish the form, download the GDB, then add any additional relates you want.  Publish this GDB as a new service.  Point the form to this new service.  You could then append in all your historical data.  You can have more relates but it must have those default ones

I seem to be in a catch-22. I have to publish a feature service to then generate a survey from, but when I publish a survey form based on a feature service I don't see it generate a GDB anywhere. It just creates a generic folder which holds the new form and web map. 

I tried following the directions in this technical report which I believe is related to what you describe, but it doesn't work for reasons that make sense to me. When I create a blank "parentglobalid" guid field in the related table and then create the relationship class (as the article describes), how is it supposed to know which rows correspond with which features?

Apologies if I am cyclic in my questions here, I greatly appreciate your assistance.

Oh, and thanks for catching that restricted field name, I made the change.

0 Kudos
DougBrowning
MVP Esteemed Contributor

The item page of the service has a export button.  I said make a Copy of the form that is not pointed to your existing layer.  That is just a trick so you can learn.

DougBrowning_0-1655322448630.png

Relationships are just a select really.  So when you say how does it know.  It doesn't.  It just goes to the other table when you ask it and looks for matching keys.  Its no more complicated than that.  

Seems like you are lacking experience in a lot of this.  It is a little more advanced.  You can hit me on a PM if you want and I could try and help.  Do you have a repeat in your form?  You did not post much to go on really.  If your form is only the trees and not the plot at all then this it would be a different workflow.  In that case you can use URLs to send the key to the form.

cphelan7
New Contributor II

It certainly does seem like my grasp of the matter is worse than I thought. I will try to get all my ducks in a row and follow your previous advice to the best of my ability before taking up any more of your time. If I really hit a wall I may take you up on the PM offer. Thank you again @DougBrowning 

DougBrowning
MVP Esteemed Contributor

I did a big writeup here.  Its old post but it works.  Similar concept  https://community.esri.com/t5/arcgis-survey123-questions/mapping-with-survey123-within-a-polygon-or-... 

0 Kudos