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?
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?
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
Ok, I've checked the variable names and the seem right. I've attached a link to a set of screen shots that show how I have the IFs set up...
https://threecatsdigital-my.sharepoint.com/:f:/g/personal/pauls_threecatsdigital_comSFU6BLF0ZEEOVWNFYY4L3G/EvN5ZDf5LwVEkgfJIvPUwKcBSI6-QT3dI_BNCYBW6v10Sg?e=oBQwmf
https://threecatsdigital-my.sharepoint.com/:f:/g/personal/pauls_threecatsdigital_comSFU6BLF0ZEEOVWNFYY4L3G/EvN5ZDf5LwVEkgfJIvPUwKcBSI6-QT3dI_BNCYBW6v10Sg?e=oBQwmf
The link is NOT working!
Well, THAT was embarrassing! Try it again - I fixed the sharing permissions.
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 ?
Well, it does look like the first IF is working, but not the nested one. I get the following:
However, there should be another line following that one, which says:
because the property type is Commercial.
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.
Please create a form copy, remove any sensitive info and upload the form backup so I can check it!
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.
[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.
Your if condition is wrong, it needs to be {data:property_type} not just property_type
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?
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.
This topic is locked and no more replies can be posted.