When sending emails to contacts using the standard...
# general
l
When sending emails to contacts using the standard transaction email button, I would like to address it to the contact name without the vendor/Customer name and colon. For example, I use the vendor.contact and it gives me Vendor : Contact Name. I'd like it to show Contact Name only. I could not find a field to use for that, so I played around with freemarker. Below isn't working. <#assign lastIndex = vendor.contact?last_index_of(':')> <#assign result = vendor.contact?substring(lastIndex + 2)> ${result}
t
vendor.contact.firstname vendor.contact.lastname
l
Unfortunately, it isn't working for me even though I have first name in the contact record. vendor.contact.entityid does not work as well.
t
try record.vendor.contact.firstname etc
ah wait no, you're using email
are you sending it "To" the contact in question? In which case, just use contact.
l
contact.firstname works. Basically, I don't need any joins aside from the contact itself. Thank you. By any chance, do you happen to know how I can make it dynamic? Sometimes we send the email to the customer or vendor itself (not to related contacts). In which case, contact.firstname would return null. Is there a way to say if the recipient is the vendor, use vendor.companyname else if contact use contact.firstname? Thanks!
m
Untested but I'm guessing something like
Copy code
<#if contact.firstname?has_content>${contact.firstname}<#else>${vendor.companyname}</#if>
l
It's odd that doesn't work. It recognizes contact.firstname if there is one but it's just null when there's no contact first name. But, if I use vendor.companyname only, it is recognized and it's working (no if's).
m
Have a read here and play around with some of the options https://freemarker.apache.org/docs/dgui_template_exp.html#dgui_template_exp_missing
You might have better luck with
${contact.firstname|vendor.companyname}
, or
<#if contact.firstname??>
or checking ?length, perhaps check the top level contact instead of contact.firstname....