I am beyond frustrated with this even after all the research and and tutorials I have been reviewing and nothing is working. This should be a very simple concept and I am missing something.
Attachment: Enter Inventory Number - The user is to enter the company inventory number (lets say 1050). From there, I would like it to automatically populate the field (Modern's Inventory Description).
I have a hosted feature layer on AGOL that has the Inventory Number and Description.
In the calculation: pulldata("@layer", "getValueAt", "attributes.DESCRIPTION", "PATH TO AGOL", ${Inventory})
However, when I enter 1050 into the survey, the Inventory Description remains blank.
Please help since I am really lost here.
Thank You
Solved! Go to Solution.
Hey there,
I got this to work! A few notes:
The calculation that did work is the following:
pulldata("@layer", "getValue", "attributes.DESCRIPTION", ${hfl_url}, ${where_clause})
Documentation:
Hope that helps!
Hey there,
I got this to work! A few notes:
The calculation that did work is the following:
pulldata("@layer", "getValue", "attributes.DESCRIPTION", ${hfl_url}, ${where_clause})
Documentation:
Hope that helps!
Question for you. I have been reworking my code in my spreadsheets for Survey123 Connect. Previously, the pulldata function was looking at a stand-alone table. Now, I am trying to pull the data from a hosted feature layer that is published from ArcGIS Pro. Some of the feature classes/fields use Domains. When I run the code for the autopopulate based on a previous entry, the field is populated with the Domain Code. That is not helpful. I need the field to populate the Domain Description. How do I ensure that happens?
Appreciate it
Hey again,
I was stumped at first but I figured out a way! For some background, pulling the label of domains is possible via the jr:choice-name() function Great blog post from Ismael here. The syntax is the following:
jr:choice-name(choice, 'question')
Here, "choice" refers to the chosen code from the attribute domain; "question" refers to the actual question within the survey where the selection is made (e.g., select_one question).
The roadblock here is that the question containing the domain must be in the survey for jr:choice-name to work. Since the goal is to get the label of the domain from a separate hosted feature layer via pulldata(), that means there is no select_one question in the survey.
Let's consider the following domain for a field called "Animal" from the feature layer we want to pulldata() from:
Code | Description |
1 | Dog |
2 | Cat |
If we used pulldata(), what is returned in the raw JSON is the code, not the description. For example:
{"attributes":{..."Animal":1,...}}
This doesn't work because we want, "Dog" not 1. We can't use jr:choice-name to retrieve "Dog" because, that domain isn't present in our survey.
However, what we can do is simulate that question in our survey. The way I did this was the following:
jr:choice-name(pulldata("@json", ${json_question}, "attributes.Animal"), '${Animal_Domain_Placeholder}')
If the value returned from the pulldata() call is '1' (referring to "Dog"), what the jr:choice-name() function is doing is basically the following:
Take the value returned from the "choice" parameter (1 in this example) and search the choices for the question stated in the "question" parameter (select_one question called "Animal_Domain_Placeholder" in this example). If found, return the label.
Since we have created the corresponding domain in our survey, it recognizes that, based on the "Animal_Domain_Placeholder" question, the value of 1 refers to the label "Dog".
It always gets a bit confusing when you nest things, but hopefully that makes sense!
I assisted me with this awhile back, but was never really able to figure out how to get it right. I've been asked to make major improvements to our initial elementary Survey123 forms and working on the design and coding in excel. Figuring this out is going to help me on a number of forms.
Thank you
My pleasure! Glad I was able to offer some help. Best of luck in the next iteration of your forms 😊
That looks like it did the trick. That is exactly what I was trying to accomplish.
(2) follow-up questions:
1: Is there a way to hide the where clause in the survey so it doesn't confuse or crowd the form for the user (Attachment).
2: In the past, when I could create and publish a survey from Survey123 Connnect and record data, other users complained they could not see recorded surveys from others. Is this a known issue or more of a lack of knowledge on my part?
Appreciate it.
Awesome! Glad that worked for you. To answer your follow-up questions:
Appreciate it. I believe this will set the foundation for what I need to accomplish.
Awesome! Happy to help 😊