You are viewing limited content. For full access, please sign in.

Question

Question

Select or Deselect a lone checkbox via Javascript (Modern Form Designer - OnPrem)

asked on December 20, 2023

My form has a checkbox, with a single choice, I would like to deselect this choice programmatically.

I have tried the following with no success:

LFForm.setFieldValues({fieldId: 10}, false);

LFForm.setFieldValues({fieldId: 10}, {value: "false"});  //I know there isn't a choice with the value "false" but I still tried!

Where the checkbox has:
Field ID = 10
Label = "Refresh"
Value = "V_true" (I set it manually to "true" it reset it to "V_true")

If anyone could point me in the right direction I would be very grateful, thank you :)

1 0

Answer

SELECTED ANSWER
replied on January 12, 2024

null did not work for me but this did: 

LFForm.setFieldValues({fieldId: 264}, {value: []});  

 

3 0

Replies

replied on December 20, 2023

I haven't played with the new javascript yet, and I don't see anything in the documentation about clearing/resetting fields, but maybe try the following:

LFForm.setFieldValues({fieldId: 10}, null);

2 0
replied on December 20, 2023 Show version history

Hi Jason, I tried your code and you are correct that this will clear all Checkbox values selected in the checkbox field. In my case field 4. The trigger fields was a SingleLine field.

LFForm.onFieldBlur(function(){ 
  LFForm.setFieldValues({fieldId: 4}, null);
},{fieldId: 1});

2 0
replied on December 21, 2023

Thank you, that worked perfectly :)

1 0
SELECTED ANSWER
replied on January 12, 2024

null did not work for me but this did: 

LFForm.setFieldValues({fieldId: 264}, {value: []});  

 

3 0
replied on January 17, 2024

Thanks Genny, your answer worked for OnPrem and the other solution worked for the Cloud.  

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.