Prepopulate field with answers from previous questions?

769
4
Jump to solution
03-28-2023 09:10 AM
choenig
New Contributor II

Hello. I am trying to have a field prepopulate an answer based on the results of previously asked questions. For example, the user is asked 1) what the date is, 2) which district they are working in, and 3) what plant they observed.

From those answers I would like to have the next question, "Site ID", prepopulate with results from these answers. For example, the Site ID would read: 0913E_TACA7_0323_001; where "0913E" is default text, "TACA7" is the plant code from a previous question, "03" is the District ID from a previous question, "23" is 2-digit year from a previous question, and "001" is the first observation of this plant (this would ideally be the only part the user would need to enter).

Please see attached image of survey form for name and labels. 

0 Kudos
1 Solution

Accepted Solutions
choenig
New Contributor II

Zach,

I think you're right that the concat() function is what I want to use here. However, I'm having some issues with the syntax. Currently I have:

concat('0913E_', ${Plant_Code}, '_', ${District_ID}, format-date(${Date}, '%y'), '_')

which is giving me the output: 

0913E__23_

It's not picking up the first two ${question} items, but does seem to like the format-date. Am I missing something?

Thanks!

View solution in original post

0 Kudos
4 Replies
ZacharySutherby
Esri Regular Contributor

Hello @choenig

You can use the concat() function in the calculate column to merge the information together. For example your concat() function could look like: 

concat("0913E_", ${plant_code}, "_", ${districtid}, format-date(${date}, "%y), "_")

Thank you,
Zach
0 Kudos
choenig
New Contributor II

Zach,

I think you're right that the concat() function is what I want to use here. However, I'm having some issues with the syntax. Currently I have:

concat('0913E_', ${Plant_Code}, '_', ${District_ID}, format-date(${Date}, '%y'), '_')

which is giving me the output: 

0913E__23_

It's not picking up the first two ${question} items, but does seem to like the format-date. Am I missing something?

Thanks!

0 Kudos
ZacharySutherby
Esri Regular Contributor

Hello @choenig

When you are seeing the 0913E__23_ output does the Plant_Code and District_ID questions have answers in the form? 

Thank you,
Zach
0 Kudos
choenig
New Contributor II

Ok, it's working. In fact, it already was, I just forgot to test it by answering the questions and seeing it populate the concatenation 🙄 🤣 Thanks for your help! 

0 Kudos