Set select_one value via If..Then

677
5
09-05-2018 12:44 PM
deleted-user-8TVt6oc0ewsX
Occasional Contributor

I have a form that uses a bar_code to populate a form via PULLDATA().  If the barcode isn't reading/working I want to allow a the user to pick from a SELECT_ONE.  How can I structure an if...then statement to say... IF BAR_CODE is != "some_default_value" (barcode IS working) THEN set SELECT_ONE to NULL.

If the bar_code cannot be read then have the user pick from the SELECT_ONE.  I have attached a form.

Thanks.

0 Kudos
5 Replies
JamesTedrick
Esri Esteemed Contributor

Hi Johnathan,

I would suggest starting by having 3 questions to resolve the ID:

1) The barcode question (id_barcode)

2) The select_one to manually pick (id_list)

3) A calculate question to select the non-null value using the coalesce() function (id_final)

   coalesce(${id_barcode}, ${id_list})

Then you can use the ${id_final} with the pulldata functions.  I would suggest having both id_barcode and id_list have the bind:esri:esriFieldType set to null so you don't have 3 different id columns writing to the table.

0 Kudos
deleted-user-8TVt6oc0ewsX
Occasional Contributor

Wow, that coalesce() function looks powerful.  I will take a look.  The other part of the question is how can I RESET the values of a Select_One to NULL or none?  If you use a bar_code I want to set the select_one to null.  If you pick a select_one I want to set the Bar_code value to NULL.   

0 Kudos
JamesTedrick
Esri Esteemed Contributor

You won't be able to have the questions set each other to null - that would create a circular calculation reference and there isn't a good way to set a question to null.  You can set half of the operations in place (i.e., if the dropdown has a value, make the barcode question non-relevant).  

The coalesce() function automatically gets the first non-null question of the two.  With the way provided above (barcode, dropdown) if the barcode question is non-relevant it will have a null value and automatically be ignored.  If the barcode question has nay value, the dropdown question is ignored.

0 Kudos
deleted-user-8TVt6oc0ewsX
Occasional Contributor

OK, thanks.  How do I make one of the "non-relevant"?  The way I have it working now is if someone picks select_one of say "1234", when they then scan a bar_code of "6789", the old value of "1234" is still shown to the user in the select_one.  this dosn't allow the coalesce() to work since both fields have values.  Is there a way to expose a RESET.  I don't want 2 values to be saved with form.

0 Kudos
JamesTedrick
Esri Esteemed Contributor

The relevant column controls whether a question submits data (and is seen for user-interactive questions). Refer to Form expressions—Survey123 for ArcGIS | ArcGIS for more information. 

0 Kudos