Hi all, we created an email script token that displays the SDR name based on logic on other custom field (POD) and the SFDC type (Lead/Contact)
It seems like it goes to the default condition ("SDR Team Lead"), and the other conditions are not calculated (Even though I checked some examples and it should work). I added below the script:
#if(${lead.SFDC_Type} == "Lead" && ${lead.POD_New__c_lead} == "01. US ENT 1")
#set($sdr_name = "Rep US ENT 1 ")
#elseif(${lead.SFDC_Type} == "Lead" && ${lead.POD_New__c_lead} == "06. US HC 1")
#set($sdr_name = "Rep US HC 1")
#elseif(${lead.SFDC_Type} == "Lead" && ${lead.POD_New__c_lead} == "07. US HC 2")
#set($sdr_name = "Rep US HC 2")
#elseif(${lead.SFDC_Type} == "Lead" && ${lead.POD_New__c_lead} == "02. US ENT 2")
#set($sdr_name = "Rep US ENT 2")
#elseif(${lead.SFDC_Type} == "Contact" && ${lead.POD_New_Contact__c} == "01. US ENT 1")
#set($sdr_name = "Rep US ENT 1")
#elseif(${lead.SFDC_Type} == "Contact" && ${lead.POD_New_Contact__c} == "06. US HC 1")
#set($sdr_name = "Rep US HC 1")
#elseif(${lead.SFDC_Type} == "Contact" && ${lead.POD_New_Contact__c} == "07. US HC 2")
#set($sdr_name = "Rep US HC 2")
#elseif(${lead.SFDC_Type} == "Contact" && ${lead.POD_New_Contact__c} == "02. US ENT 2")
#set($sdr_name = "Rep US ENT 2")
#else
#set($sdr_name = "SDR Team Lead")
#end
##print the SDR name
${sdr_name}
Can you let us know if there's a syntax issue we're missing?
Thanks!
Itay
Solved! Go to Solution.
Did you check the respective fields like "SFDC Type" in the right hand side nav of the token?
We’d need to see the raw values of your relevant fields ($lead.POD_New__c_lead, $lead.POD_New_Contact__c, $lead.SFDC_Type). Otherwise, it’s impossible to know whether the output is expected or not. As Michael mentions, you may not have checked them off in the tree.
Regardless, you should be avoiding formal references and the == operator. Both of these can cause hard-to-find bugs. Instead, use simple references and equals().
#if( $lead.SFDC_Type.equals("Lead") && $lead.POD_New__c_lead.equals("01. US ENT 1") )
#set($sdr_name = "Rep US ENT 1 ")
#elseif( $lead.SFDC_Type.equals("Lead") && $lead.POD_New__c_lead.equals("06. US HC 1") )
#set($sdr_name = "Rep US HC 1")
#elseif( $lead.SFDC_Type.equals("Lead") && $lead.POD_New__c_lead.equals("07. US HC 2") )
#set($sdr_name = "Rep US HC 2")
#elseif( $lead.SFDC_Type.equals("Lead") && $lead.POD_New__c_lead.equals("02. US ENT 2") )
#set($sdr_name = "Rep US ENT 2")
#elseif( $lead.SFDC_Type.equals("Contact") && $lead.POD_New_Contact__c.equals("01. US ENT 1") )
#set($sdr_name = "Rep US ENT 1")
#elseif( $lead.SFDC_Type.equals("Contact") && $lead.POD_New_Contact__c.equals("06. US HC 1") )
#set($sdr_name = "Rep US HC 1")
#elseif( $lead.SFDC_Type.equals("Contact") && $lead.POD_New_Contact__c.equals("07. US HC 2") )
#set($sdr_name = "Rep US HC 2")
#elseif( $lead.SFDC_Type.equals("Contact") && $lead.POD_New_Contact__c.equals("02. US ENT 2") )
#set($sdr_name = "Rep US ENT 2")
#else
#set($sdr_name = "SDR Team Lead")
#end
##print the SDR name
${sdr_name}
Hi @SanfordWhiteman, that's correct, I forgot to check the fields that I used on the tree. I did that now and looks like it's working
Thanks
Itay
I'm thrilled the other guys got you over the line. I thought I'd comment on the coding itself (in the interest of making your life easier in the future).
This is the approach I'd take:
#set( $PODtoSDR = { "01. US ENT 1" : {"SDRName":"Rep US ENT 1"},
"06. US HC 1" : {"SDRName":"Rep US ENT 1"},
"07. US HC 2" : {"SDRName":"Rep US HC 2"},
"02. US ENT 2" : {"SDRName":"Rep US ENT 2"}
})
#if( $lead.SFDC_Type.equals("Lead"))
#set($sdr_name =$PODtoSDR[$lead.POD_New__c_lead].SDRName)
#elseif( $lead.SFDC_Type.equals("Contact") )
#set($sdr_name =$PODtoSDR[$lead.POD_New_Contact__c].SDRName)
#end
#if (! $sdr_name )
#set($sdr_name = "SDR Team Lead")
#end
##print the SDR name
${sdr_name}
So, step wise:
FWIW - I've not had a chance to actually execute my code above, so it's probably got a few errors, but the concept is correct and is super easy to extend (just add more values to the map at the top.. no other code changes required). If you ended up with different allocation rules for leads vs. contacts, you could create a second value like so
#set( $PODtoSDR = { "01. US ENT 1" : {"contactSDRName":"Rep US ENT 1",
"leadSDRName":"Bob"},
"06. US HC 1" : {"contactSDRName":"Rep US ENT 1",
"leadSDRName":"Jane"},
"07. US HC 2" : {"contactSDRName":"Rep US HC 2",
"leadSDRName":"Mike"},
"02. US ENT 2" : {"contactSDRName":"Rep US ENT 2",
"leadSDRName":"Sue"}
})
And refer to each of either .contactSDRname or .leadSDRname in the if statement in step 2.
Hopefully that is helpful/useful to you (and please take this whole post in that spirit)
Cheers
Jo