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


TEXT(anyField) returns null in HTML email templates;


  • 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
  • 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 Jun 12 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 Jun 12 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 Jun 12 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 Jun 17 at 3:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.