Conditions: Possiblity to use parenthesis

  • jrleichter
    Asked on September 16, 2020 at 11:50 AM

    Hi - We are using Jotform for a Covid questionnaire for a large building. I'd like to create a condition with multiple pieces of logic.

    For example:

    Question 1: Are you a guest or an employee? Yes / No

    Question 2: Have you tested positive for covid in past 14 days? Yes / No

    Question 3: Have you been outside the country in past 14 days? Yes / No

    Question 4: Has someone in your home tested positive? Yes / No

    Desired Logic: If Q1 is "Yes" AND (Q2 is "Yes" OR Q3 is "Yes" OR Q4 is "Yes"), send Email to jon@smith.com

    Is this possible?

    Or do I have to create a new Condition for every separate permutation?

    Thanks! You are all awesome!

  • David JotForm Support Manager
    Replied on September 16, 2020 at 1:22 PM

    Good day, you don' t need to create a separate notification per each permutation, you can create nested conditions. What is the form that you are currently working on? This appears to be the last form you edited, but none of those questions are present.

  • trhcux
    Replied on September 16, 2020 at 10:50 PM

    Following…


  • fcjaforms
    Replied on September 16, 2020 at 11:29 PM

    Thanks BDavid. I'm not sure what form that is, but it's not ours. Regardless, how do I add a "nested condition" - I don't see that referred to clearly in the User Guide.

    If it helps, let's say the form has 15 questions:

       Q1: Are you an employee? Yes / No

       Q2 thru Q15: Various Yes / No questions

     

    My hope is to create a condition whereby an email is sent to jon@smith.com if:

       Q1 = YES

       AND

       Any of Q2-Q15 is YES (if the user answered YES to at least one of them)

     

    And then I would create another condition whereby an email is sent to mary@smith.com if:

       Q1 = NO

       AND

       The user answered YES to at least one of Q2-15

     

    Is this possible with nested conditions?

    THANK YOU

  • Vanessa_T
    Replied on September 17, 2020 at 1:15 AM

    Since conditions can only be either AND or OR, without a way to pair it with another group of fields, what you want need requires 14 conditions when Q1 is YES, then another 14 conditions when Q2 is NO.

    However, as a workaround, I suggest adding a Form Calculation widget that concatenates the answers from Q1-Q15.

    https://www.jotform.com/widgets/calculation

    Then create a condition like the one below.

    1600319454 5f62efde79a22 01591 Screenshot 10

    How-to-Send-Email-Based-on-User-s-Answer

    Basically it checks if Q1 is Yes, then anywhere on the other questions is No. You'll have to make the opposite also for when Q1 is No.

  • fcjaforms
    Replied on September 17, 2020 at 8:22 PM

    Thanks Vanessa_T. Does that mean that BDavid's suggestion about Nested Conditions won't work?

    I feel like you understand my need and your work-around suggests that I would only need two conditions - but I'm really not following how to use Form Calculation to solve this. Can you explain it in a little more detail to a novice? I feel like you may mean that I should assign values of No=0 and Yes=1 to Q2-15 but I'm not sure... THANK YOU!

  • Jono
    Replied on September 17, 2020 at 10:19 PM

    See if this helps:

    1. Add the Form Calculation Widget to your from & name it Concat

    2. Add questions 2 - 15 to the Form Calculation element using the green "Add Element"

    3. Create the conditions outlined above


    Adding your Yes/No question fields to the Form Calculation widget will allow the Condition to check the Concat values to see if any of them contain yes or no, or start with yes or no, as prescribed above.

  • Vanessa_T
    Replied on September 18, 2020 at 12:22 AM

    If I'm not mistaken, what BDavid meant on nested condition is having multiple fields checked within one condition, however, as previously mentioned, we don't have a way to pair one question and group which is the equivalent of parenthesizing Q2-Q15.

    Kindly try out my suggestion instead. You may refer to the screencast below to help you get started:

    1600402856 5f6435a81c781 A Screenshot 10

  • fcjaforms
    Replied on September 20, 2020 at 11:58 PM

    Vanessa - got it! Thanks for your help. This is a smart solution for a work-around. I'm not going to tell you that my form is multi-lingual and that I need to change all the answers so that the condition works with the concatenated field regardless of the form's language. All this would have been easier with the ability of some simple parentheses and And/Or functionality, but I understand that isn't available (yet?). Thanks again.

  • Sonnyfer JotForm Support
    Replied on September 21, 2020 at 4:20 AM

    Glad to hear that our workaround works for your requirement.

    As for the parenthesis for the And/Or functionality in conditions, I'm afraid you are right, we do not support it at the moment.

    Let me escalate the idea to our developers as a Feature Request to check if this is something that can be implemented in the future. Though we cannot give you an ETA, rest assured you'll be informed here for any updates.