Pre-populating text is not working while switching the radio buttons

Hi,

Greetings of the day!
This is regarding the Pre-populating text is not working while switching the radio buttons while texting the form in Hybrid platform after deploying.
Requirements:

Requirement 1) Our form requests User to fill 2 fields.
First Field is a Radio button with Choices as Yes,No and N/A (say the field name is YES_NO_NA )
Second Field is a Free text box which User can edit and type whatever is required (say the field name is SIGNIFCANT_DETAILS )

Requirement 2) If User selects β€œ Yes ” from the first field, then we require the second field to be pre-populated with a defined response as β€œ The premises is only occupied by residents ”

Requirement 3) If User selects β€œ N/A ” from the first field, then we require the second field to be pre-populated with a defined response as β€œ N/A ”

Requirement 4) If User selects β€œ No ” from the first field, then we require the second field NOT to be pre-populated so the User can update his own comments (second field being a free text)

Requirement 5) when user is selecting the radio button β€œYes” the Pre-populated text is displaying and when he changed his choice to β€œN/A” and selected the radio button β€œN/A” the Pre-populated text is displaying correctly but at the third time when he is changing his choice from β€œN/A” to β€œYes” the Pre-populated text is not displaying.

Approach

We have defined 2 fields as required (i.e. YES_NO_NA and SIGNIFCANT_DETAILS ).

We downloaded the Forms .xls format

In the .xls format, For the second field we have used the calculate column and updated the below a formula

if(${YES_NO_NA}=β€˜Yes’,${SIGNIFICANT_DETAILS_Yes},(if(${YES_NO_NA}=β€˜N/A’,${SIGNIFICANT_DETAILS_NA},${SIGNIFICANT_DETAILS})))

The above approach has solved our Requirements 1,2, 3 and 4 but NOT Requirement 5

Please suggest the right approach to meet this requirement. Please note we have tried in kobotoolbox.org it is working fine but whereas in Hybrid.

Please find the below attached file.
SAMPLEFORM.xlsx (12.7 KB)

Many Thanks
Keerthi

Dear @keerthi,
may be the following can help. Instead of using default, use once(β€˜N/A’). Default is only activated one time. But once(…) can re-activate when the field becomes empty again (depending on navigation and dependencies!).
Here your example, a bit adapted for easier testing.
SAMPLEFORM 02.xlsx (12.2 KB)
I added a suffix to some labels and put the last calculate var temporarily to text type, for testing.
Take care of some limits with once(): https://docs.opendatakit.org/form-logic/?highlight=default#setting-default-responses

Side-notes:

  1. I was surprised how you made it: 3 variables with the same label, and then compiling the result with a calculate (4th) variable. Why not use one text field with a dynamic once( if(…) ) pre-set, for the cases where you allow the user to enter or change the text. And a second calculate var (which can integrate a fixed text case).
  2. You do not need false for required, this is the KoBo default? (If you want other fields as required, you would need to set them to true.)
  3. Better not use / in names? (N/A). β€œNames can only contain letters, digits, hyphens, underscores, and periods.” (xlsform.org)

Kind regards

1 Like

Hi @keerthi
Your function should work as you have indicated above however I think this is beyond the scope of what Kobotoolbox since you clearly state that this does not seems to work only on Hybrid.

Could you provide more details on the Hybrid you are talking about and check if there is a different support for the Hybrid system.
Stephane

1 Like