Copy link to clipboard
Copied
I am new to coldfusion and need to create an automated email that will send emails depending on what the company name is. I can get the cfif / cfelse statement to work properly. When I try to get the cfif / cfelseif / cfelse the cfelseif appears to not be evaluated. Here is a segment of code.
<cfquery name="get_ticket_info" datasource="#application.datasource#"username="#application.datasource_username#" password="#application.datasource_password#">
SELECT * FROM
tbl_Tickets
WHERE ID_NO = <cfqueryparam cfsqltype="cf_sql_smallint" value="#id#">;
</cfquery>
<cfif get_ticket_info.customer_name is "Company A"><cfset tolist="john.doe@companyA.com">
<cfelseif get_ticket_info.customer_name is "Company B"><cfset tolist="jane.doe@companyB.com">
<cfelse><cfset tolist="frank.doe@companyY.com">
</cfif>
I troubleshoot if/else logic by looking at the data. For your example, it would be something like this:
<cfdump var="#get_ticket_info#" metainfo = "no">
<cfif get_ticket_info.customer_name is "Company A"><cfset tolist="john.doe@companyA.com">
<br> is company a
<cfelseif get_ticket_info.customer_name is "Company B"><cfset tolist="jane.doe@companyB.com">
<br> is company b
<cfelse>
<cfset tolist="frank.doe@companyY.com">
<br> is neither company a nor b.
<br><cfdump var = "_#get_ticket_info.customer_name#_"
...Copy link to clipboard
Copied
I troubleshoot if/else logic by looking at the data. For your example, it would be something like this:
<cfdump var="#get_ticket_info#" metainfo = "no">
<cfif get_ticket_info.customer_name is "Company A"><cfset tolist="john.doe@companyA.com">
<br> is company a
<cfelseif get_ticket_info.customer_name is "Company B"><cfset tolist="jane.doe@companyB.com">
<br> is company b
<cfelse>
<cfset tolist="frank.doe@companyY.com">
<br> is neither company a nor b.
<br><cfdump var = "_#get_ticket_info.customer_name#_">
</cfif>
<cfabort>
Copy link to clipboard
Copied
Dan,
By taking your suggestion I discovered a space at the end of the company name. Thank you for your assistance.
Copy link to clipboard
Copied
Nothing jumps out at me as incorrect. My guess is no customer_name is "Company B". Maybe the name is space padded? Try using <cfdump var="#get_ticket_info#" /> or use cflog to log various values and compare the data yourself.
Copy link to clipboard
Copied
Steve,
That is exactly what it was. Thank you for your suggestion.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now