Nested IF condition actions

How to use nested IF conditions in ChronoForms actions.

Overview

The issue occurred because the nested IF condition used an incorrect variable reference without the required data: prefix.
Ensure all IF conditions reference form data fields using the correct {data:field_name} shortcode format, not just the field name, to allow proper evaluation and nesting.

Answered
ChronoForms v6
th threecats 30 Jun, 2019
Is it possible to use nested IF conditions in an action string? I have an if condition in which , if a field called contact_purpose NOT EQUALS question, it runs a rule called insp_appt. That rule does a Data Builder action which creates a text string, then runs another IF condition which, if a field called property_type is equal to Commercial, it's supposed to run a rule called commercial_insp_appt - this rule creates a second text string.

In other words, the logic is supposed to look like this (using pseudo-php)

if ($contact_purpose <> "question" {
text_string_1 = "This is a " . $property_type . "property located in " . $location;
if ($property_type == "Commercial" {
text_string_1 = "The name of the business is " . $business_name;
}
}

The way it's set up in ChronoForms, the first IF works fine - in other words, if it's not a "question" it creates the "This is a Commercial property located in Atlanta" (or, Residential, if that's appropriate). However, it never runs the second IF - even if you specify a Commercial property type, which is the trigger.

So, are nested IFs allowed? If so, what am I doing wrong?
he healyhatman 30 Jun, 2019
Should be allowed, I've done it a bunch. Make sure you're using the correct option for the data builder and using the correct shortcode to retrieve the value
Max_admin Max_admin 02 Jul, 2019
The link is NOT working!
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
th threecats 02 Jul, 2019
Well, THAT was embarrassing! Try it again - I fixed the sharing permissions.
Max_admin Max_admin 03 Jul, 2019
I tested here with message actions instead of data builder and the nested if is working fine, could you please use messages to test and let me know ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
th threecats 03 Jul, 2019
Well, it does look like the first IF is working, but not the nested one. I get the following:

Name: Paul
Phone Number: 1234567890

This is a Commercial property located in Atlanta.


However, there should be another line following that one, which says:

The name of the business is Nonna Yours


because the property type is Commercial.
Max_admin Max_admin 04 Jul, 2019
Please create a form copy, remove any sensitive info and upload the form backup so I can check it!
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
th threecats 04 Jul, 2019
OK, I've uploaded it...
​[file=https://www.threecatsdigital.com/Contact Form_04_Jul_2019_08_48_59.cf6bak]Form Backup[/file]
By the way, I couldn't get it to upload - had to create a link.
he healyhatman 04 Jul, 2019
Answer
Your if condition is wrong, it needs to be {data:property_type} not just property_type
th threecats 04 Jul, 2019
Huh. Well, that did work. I wonder why it needed to have the data: specified, when it doesn't for the earlier if which simply uses contact_purpose...? Or is that just a "bug" which allows it to work anyway?
he healyhatman 04 Jul, 2019
Does "contact_purpose" equal "question" ? You might as well have said "IF 1 = 2". That if condition will ALWAYS be not equal. You need to replace that with {data:contact_purpose} as well.
th threecats 04 Jul, 2019
Got it, Not sure why it was working before, - could have been just checking a particular set of options - but it's working perfectly now. Thanks for ALL your help!
This topic is locked and no more replies can be posted.