What is the structure of an if/else statement in Survey123?
I'm trying to check the username of the user, if true then grab the answer from a select one question, if not then just grab the username from the username question type. No luck so far
To provide some info to your response:
The workflow is the following:
So if I understand correctly, it sounds like you have two conditions to trigger ${Call_In_Name} being used in the textbox:
For the second condition, you state "if the username is already in there and the user clicks on the select one question." Are there any situations where ${Call_In_Name} is selected, but you still want to use ${Name} instead? If not, then this should probably do what you need:
if(string-length(${Call_In_Name})>0, ${Call_In_Name}, ${Name})
This checks to see if ${Call_In_Name} has been answered, and if so, grabs that value. If not, ${Name} is used instead.
And just in case someone has 'Internal' for ${Name} but tries to skip answering ${Call_In_Name}, you can put this condition in the required column for ${Call_In_Name}:
if(${Name}='Internal')
(note, conditionally required questions apparently don't work in web forms)
With this setup, the textbox will always equal the ${Call_in_Name} as long as that question is answered. If instead you want to use ${Name} all the time unless A) it's 'Internal' or the user wants to optionally override it, you'll need to do that with at least another question and some additional statements.
I have this:
if(${Name}='Internal', ${Call_In_Name}, ${Name})
Where Name is the name of the account
Call_In_Name is a select one answer
This is going into a textbox. I want to grab Call_In_Name if the username (Name) is equal to "Internal", else just grab the username (Name) and put it into the textbox
There is also a requirement to overwrite what's in textbox if the username is already in there and the user clicks on the select one question
From the documentation:
if(condition, a, b)
Where:
The linked page has plenty of functions and operators to help you set up your if condition. If you're still stuck, describe exactly what you're trying to check and how, and someone can try to help you further.
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.