0

I have an email template in which I need to display a person's role, but I need to determine whether the role starts with a vowel (eg Accountant) so that I can correctly display 'a' or 'an' before it in the sentence. Eg:

'I, as an Accountant.... or 'I, as a Lawyer...

Currently I have: I, as {!IF(BEGINS(object__c.Role__c,'A'),'an','a')} {!object__c.Role__c}, ...

but it's not returning anything for me. Can I use BEGINS here or do I need to use something else?

Here's what I see when I just put the options into the template. Neither the BEGINS or LEFT options return anything? enter image description here

1 Answer 1

1

TEXT(anyField) returns null in HTML email templates;

Options

  • Can you use a VF email template instead? You have much more expressive power in formulas
  • Create a formula field on your object RoleAsText__c = TEXT(Role__c) and refer to {!...RoleAsText__c ...} in your email template formulas
4
  • I would prefer not to have to go into that work just to accommodate whether to use 'a' or 'an', so was hoping I could just use a formula. So are you saying that I cannot use the LEFT or BEGINS formula function on a picklist field?
    – Irene
    Commented Jun 12, 2019 at 2:45
  • @Irene Shoot. I'm pretty sure cropredy's right. The basic template merge feature is kind of useless. It's been a while since I've used it, so it's probably right.
    – sfdcfox
    Commented Jun 12, 2019 at 3:00
  • @Irene - yes, I placed a simple {!TEXT(Contact.FirstName)} in an email template and saw that the result is NULL. Picklists require wrapping with TEXT to inspect the characters so you are out of luck. It is for reasons like this that I tend to use VF email templates so I'm not hamstrung nor reduced to hacks
    – cropredy
    Commented Jun 12, 2019 at 3:20
  • I was considering using a VF template, but then I can't set the recipient to my custom field in my custom object. The recipient is neither a contact, lead or user, but a name and email address on my custom object. It looks like my only option therefore is to create a formula field on my object to determine the role. Not ideal.
    – Irene
    Commented Jun 17, 2019 at 3:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .