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

Question

Question

Forms - Formula to get chosen values from a checkbox

asked on September 10, 2024

I can not seem to a find a formula for this. They just want to include all the chosen values from a checkbox field named Facilities Requested. Is there any formula to get only the chosen values of a checkbox?

I can only choose optional values here and could not find a function by searching the documentation for "checkbox" or "values"

I tried this

=IF(FACILITY_REQUESTED.Choice_1,FACILITY_REQUESTED.Choice_1,"")

But it just returns True and it would not account for changes to the field over time anyways so it is not a proper solution. Especially if I hardcoded the values.

What is the proper way to get all choices selected in a checkbox field?

0 0

Replies

replied on September 10, 2024 Show version history

Hey Chad,

One way to do it, though it is more manually tedious and doesn't account for dynamic adding of options (so if another option got added to the checkbox field, it would have to be added in the formula as well) is to put each option in an IF statement there to see if they are selected and add them together.  I added like 4 spaces just to separate them but you could do something like this:

 

=IF(FACILITY_REQUESTED.Classroom, "Classroom", "")&"    "&IF(FACILITY_REQUESTED.Cafeteria, "Cafeteria", "")

Of course you would have to do that for each option though. 

0 0
replied on September 10, 2024

Ok gotcha, this is what I started to do but I feel it would break very easily as it is not synced with changes that users make to the checkbox field.

Instead I am using this LFForm object rather than a calc.

LFForm.subscribe(
  "fieldChange", () => { 
    let values = LFForm.getFieldValues({fieldId: 17}).value;
    let result = '';
    values.forEach((element) => result+=element+',');
    result = result.substring(0, result.length-1);
    LFForm.setFieldValues({fieldId: 68}, result);
  }, {variableName: "FACILITY_REQUESTED"});

It works great except it can not read data literally and replaces space characters, slash characters, etc with underscore characters. I have not selected to add alternate values to the checkbox but it does this character replacement anyways. This is where raw javascript is more powerful as I can read data without losing characters.

0 0
replied on September 11, 2024

Just to clarify, are you just wanting to compile a summary/list of all items selected?

If so, and if you're okay having the list show on a secondary form, or just in metadata in the repository, you have the option to select <list of all checked> (last option) either in the default value box of a single line/multi line field on your secondary form, or in the Configure Fields dialogue box on a Save to Repository task. Both will list the values with commas separating them.

0 0
replied on September 11, 2024

They have an option to add an event to their calendar while using the form and want to include the checked options in the description of the event. So there is no opportunity to do anything on the process diagram here.

0 0
replied on November 7, 2024 Show version history

I ended up using a multi-line field with a formula.

 

Deny Reason Multiline formula:

=CONCATENATE(

IF(Deny_Reason.Invalid_request = TRUE, "- " &"This is an invalid request" & CHAR(10),"")

,
IF(Deny_Reason.Expired = TRUE,  "- " & "The deadline has been expired" & CHAR(10),"")

,
IF(Deny_Reason._other = TRUE, "- " & Deny_Reason._other_data & CHAR(10),"")

)

 

 

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

Sign in to reply to this post.