I have a job of which a section of an alterState call contains the script captured below. I was looking to reassign some of the values from a data variable depending on the values of 2 other variables in the dataset, but I don’t know where I should insert the line of code to do this in the job script.
The idea was to assign the value of the variable bns_matrix_radio/bns_matrix_radio_number to 1 if:
- the value of bns_matrix_radio/bns_matrix_radio_possess is ‘yes’ AND
- the value of formName is ‘BNS Makira 2019’.
If these conditions are not met, the value of bns_matrix_radio/bns_matrix_radio_number should stay as it is.
The code I had in mind to do this would look a bit like this:
‘NAME OF COLUMN IN DATABASE TABLE THAT HOLDS VALUES OF bns_matrix_radio_number’: state => (dataValue(‘body.bns_matrix_radio/bns_matrix_radio_possess’) === ‘yes’ && dataValue(‘formName’) === ‘BNS Makira 2019’ ? 1 : dataValue(‘body.bns_matrix_radio/bns_matrix_radio_number’)),
Where would you recommend to insert this data cleaning code in the job script? Would it be in-between the curly bracket and the bracket of line 92 (before closing the .map called line 69), or on line 93 so it is separate from what’s happening in lines 67 to 92, or somewhere else?
Thanks for your help!