Select to view content in your preferred language

Setting a question to NULL in a if/else statement

139
3
4 weeks ago
ChristianCordova
Emerging Contributor

Hi there, wondering if there exists a way to set a question to NULL (or None) inside a if/else statement.

I have a kind of large survey where at the begin I call a pulldata() function to know if a register exists, then save the globalid as question (${feature_globalid}).

After that in another question, I check if there exists such feature using: string-length(${feature_globalid}) > 0 , to avoid calling pulldata to get other properties (from relationships tables).

So, in the calculation column, I am using something like this:

if(string-length(${feature_globalid}) > 0, pulldata("@layer", "getValue", "attributes.x", ${url_y}, ${where_z}), '')

but I DO not want to fill te question with '' when there is no exist such feature.  I want the question to be NULL (for webhook reasons).

I know I can just call pulldata() (and return NULL when no the feature is not found) directly without previous check, but as I need to call pulldata() many times after.

 

When using the '' inside the if/else statement, when changing the question value a double arrow symbol appears which is annoying (and if I press the double arrow symbol it undoes the question value).

 

Thanks in advance!

0 Kudos
3 Replies
DougBrowning
MVP Esteemed Contributor

Common issue is pulldata does not like being inside of an if or any other function.  Move the pulldata to its own field then use that field in the if.  

ChristianCordova
Emerging Contributor

Thanks DougBrowning for the temp solution. Unfortunately, moving the pulldata() as a new question means creating many new questions just for pulldata. I am working with a large survey (land administration) and like 80 or more questions are using pulldata (from many other tables). 

DougBrowning
MVP Esteemed Contributor

Sorry but it has been like this for years so it is probably not going to change anytime soon.  Also 80 pulldata calls would probably make your form rather slow.  May want to consider a different workflow.

0 Kudos