• Resolved dlajeune

    (@dlajeune)


    I want a calculated field to perform an operation ONLY if a specific checkbox is checked.
    Setup
    Fieldname1: abc
    Fieldname2: def
    Fieldname3: ghi
    Fieldname4: checkbox with 3 items (“First”, “Second”, “Third”)

    Calculated field 1 (to be calculated only if “First” is selected) Fieldname1*Fieldname2
    Calculated field 2 (to be calculated only if “Second” is selected) Fieldname2*Fieldname3
    Calculated field 3 (to be calculated only if “Third” is selected) Fieldname1*Fieldname3

    I can’t seem to figured out how to check Fieldname4 to see if a specific box is checked.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @dlajeune

    The issue is simple:

    – Go to the settings of the fieldname4 field, an untick the checkbox: “Merge ticked up options (sum or concatenation) or their values are returned as an array” in its settings (now the value of field would be an array whose items are the values of choices ticked).

    – And then, use the IN operation in the equation. The IN operation returns true if the first parameter is in the array passed as the second parameter:

    * The equation to associate to the first calculated field would be:

    
    IF(IN('First', fieldname4), fieldname1*fieldname2, '')
    

    * The equation associated to the second calculated field:

    
    IF(IN('Second', fieldname4), fieldname2*fieldname3, '')
    

    * The equation associated to the third calculated field:

    
    IF(IN('Third', fieldname4), fieldname1*fieldname3, '')
    

    If you want that the calculated fields be visible only when their corresponding choices are ticked, then you can forget all previous instructions and simply define dependencies between the choices in the fieldname4 field, and the corresponding calculated fields, as describe the following post in the plugin’s blog:

    https://cff.dwbooster.com/blog/2020/03/01/dependencies/

    Pay attention, javascript is a case sensitive language, be careful with the use of uppercase and lowercase.

    Best regards.

    Thread Starter dlajeune

    (@dlajeune)

    Thank you!!!! Worked perfectly.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get value from on box in checkbox list’ is closed to new replies.