Populate current field based on previous answer...sometimes

05-03-2018 09:21 AM
Occasional Contributor III

Hello James Tedrick‌, Ismael Chivite‌,

I am attempting to create the following calculation:

  • If the value of {CANNOT_LOCATE} is set to 'YES' then set my current field to 'UNKNOWN'.
  • If the value of {CANNOT_LOCATE} is set to 'NO' then don't pre-populate my current field and let the user choose from the list of choices.

I can achieve the first part using:

if(selected(${CANNOT_LOCATE}, 'YES'), 'UNKNOWN','')

However, if the value of {CANNOT_LOCATE} is set to 'NO' the value chosen for my current field is considered ineligible and gets the strike through as it's not ' '. So, I tried the following:

if(selected(${CANNOT_LOCATE}, 'YES'), 'UNKNOWN',if(selected(${CANNOT_LOCATE}, 'NO'), 'NO',''))

This works, and even if I change my current fields value from "NO" to something else on the choice list it's accepted. However, it does pre-populate my current field with a "NO" meaning a user could technically skip over this field. I'd much prefer to leave my current field BLANK if the value of {CANNOT_LOCATE} is set to 'NO'.

Any advice?

0 Kudos
2 Replies
Esri Esteemed Contributor

Hi Andrew,

Unfortunately, the if() function must have both a value when true and a value when false, so you cannot accomplish this precise experience in a single question.  You can create a similar experience:

1) Have your dropdown question (${DROPDOWN}) be relevant based on the value of ${CANNOT_LOCATE}.  The dropdown question will also have a bind::esri:esriFieldType of null (it's a visual element; the data is stored in the next question).

2) Have a calculate question store the answer with the formula to evaluate:

if(selected(${CANNOT_LOCATE}, 'YES'), 'UNKNOWN', ${DROPDOWN}) 

0 Kudos
Occasional Contributor III

James Tedrick‌ I was unable to include the ${DROPDOWN})  in a calculation without getting an error. Instead I added 'PLEASE_ANSWER' to each of my choice lists and calculated that to be the default answer. It's a bit of a pain as it's now a possible answer a user can choose and so now I must also include a constraint for each question stating that ${DROPDOWN}!='PLEASE_ANSWER'.


0 Kudos