Two questions. I have an Email template for Case object. Basically I was able to add many fields in the case object itself using {!relatedTo.casefieldname}format. Now I need to add some case owner information like owner name, role etc... But when I add user role like,


it keep showing me an ID only, not an exact value. Not sure how can I achieve this?

Next question is i also need to add an URL within the template itself. So I hard coded the URL. But when we generate the email, the hard coded url is scrambled. So any best practices to hard code URL?

1 Answer 1


You won't be able to direct access the case owner name, role for that you have query, please find the solution below : -

  1. your email template is correct, just use component like below : -

Apex component :

<apex:component controller="findSmithAccounts" access="global">
    <apex:dataTable value="{!SmithAccounts}" var="s_account">
            <apex:facet name="header">Account Name</apex:facet>
  1. Query your owner Name and role in the controller like below : -

    SELECT Name,UserRoleId FROM User WHERE Id IN (SELECT OwnerId FROM Case WHERE Case.CaseNumber = '00001234')

  2. use the component in the email template.

  • Thanks, what about the second question, the hard coded URL? Commented May 8, 2017 at 9:50
  • @L Mudiyanse, if it working then accept and upvote the answer so that other can found it useful.
    – Avijit Das
    Commented May 8, 2017 at 10:01
  • "hard coded URL" i didn't get you ??
    – Avijit Das
    Commented May 8, 2017 at 10:02

You must log in to answer this question.

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