How can I create a condition on a matrix?

  • cgalarza
    Asked on September 29, 2016 at 10:06 AM

    Hello, 

    I have a matrix titled Health History Past or Present on my form: https://form.jotform.com/62645906652159. The first ten choices have an asterisk next to it to indicate to parents that if they select YES to any of those asterisk items then we are going to need an additional form to be filled out. I have two autoresponders emails set up. One is for everyone who hits submits will receive. The 2nd is identical to the first except I want anyone who marks YES to any of the asterisk items in the matrix to receive the 2nd email which has the additional form they need attached instead of Email 1. 

    I was trying to figure out how to set up the condition to do this but I wasn't able to figure it out. Will I have to make 2 separate matrixes? One for the asterisk items and the other for those who don't require an additional form? 

    Thanks!

  • Charlie
    Replied on September 29, 2016 at 1:12 PM

    Unfortunately, you cannot set it up like this:

    How can I create a condition on a matrix? Image 1 Screenshot 70

     

    The reason is because your first "IF" statement cannot identify the "*" on the value of the matrix field, because the answer depends on the column selected. In your case, the columns are "YES" and "NO". Another problem is that the matrix field consists of multiple rows, meaning it does not output a single input, meaning have the 2nd "IF" statement will not work because you have multiple rows.

    What might work is setting up a form calculation widget to fetch the input for the rows with "*".

    Here's how:

    1. First, add a form calculation widget in your form. This is the field that will fetch all the input from rows 1-10 of your matrix field.

    How can I create a condition on a matrix? Image 2 Screenshot 81

     

    2. Now in the widget setting, add the specific rows from the matrix field that needs to be checked or evaluated. Use the "Add Field" button. Here's a screencast to show how I added mine:

    How can I create a condition on a matrix? Image 3 Screenshot 92

    Notes
    - Make sure to set the input type from "0-9" to "A-Z".

    - Separate each field with a space or a comma.

     

    3. The final output would look like this:

    How can I create a condition on a matrix? Image 4 Screenshot 103

     

    4. In your live form, you can see that the first ten rows (the ones with the asterisk will have the inputs in your form calculation widget.

    How can I create a condition on a matrix? Image 5 Screenshot 114

     

    5. Now based from that widget, we can now rewrite your conditional logic for the autoresponder to something like this:

    How can I create a condition on a matrix? Image 6 Screenshot 125

    So what my condition states that if the field "Rows 1-10" widget CONTAINS a value of "YES", meaning any of the rows has an answered "YES", then send the "Autoresponder - Doctor's note" to the specific address. 

     

    I hope that helps.

    Note: You need to specify the email field name in your conditional logic to where to send the autoresponder. You can learn more about the conditional logic for email alerts on this guide: https://www.jotform.com/help/167-How-to-Send-Email-Based-on-Selection