1

I want to make an email alert if a rep has left the company (Rep profile user account deactivated) and has outstanding programs.

So I want to put in the email template his name, his role, and his outstanding programs if any, but I got stuck. I got an email alert with the username, with {!Target_User.Name} in workflow rule but his role and his outstanding programs don't show.

This email template not getting required information

"

Hi {!Receiving_User.Name},

This has been observed that rep user got deactivated and his details as below.

Name : {!Target_User.Name} ,

Employee Role:

Termination date: {!Today};

Outstanding Programs:

"

I am getting rep profile name and termination date if I deactivate rep profile user but his role and outstanding programs which he is the owner not getting. Rep user is the employee of the org so we have custom object Employee and in that custom object, we have related list for participant which has that programs name, role, status. How can I put it this deactivated rep user information in the email template where Home office user will get it.

0

Since you have Employee object which contains Employee Name and other information and related Object which holds programs name, role and status. You need to build Visualforce email template. Refer Create Visualforce Email Templates

Email Template of your requirement will look like this

<messaging:emailTemplate subject="<put your subject>" recipientType="Employee__c" relatedToType="Employee__c"> 
    <messaging:plainTextEmailBody > 
    Hi {!Receiving_User.Name},

    This has been observed that rep user got deactivated and his details as below.

    Name : {!Target_User.Name} ,
    </messaging:plainTextEmailBody> 

    <messaging:htmlEmailBody> 
        <!-- loop through related list records to display attributes like role, outstanding programs etc. -->

        <apex:repeat value="{!relatedTo.Paticipant__r}" var="tx" > 
        <tr>Employee Role:
            <td>{!tx.RoleName__c}</td> 
        </tr>
        <tr>Termination date: 
            <td>{!Today};</td> 
        </tr>
        <tr>Outstanding Programs:
        <td>{!tx.Programs__c}</td> 
        </tr>

        </apex:repeat> 
    </messaging:htmlEmailBody> 
</messaging:emailTemplate>

Refer Visualforce Email Template Sample

Attributes of messaging:emailTemplate

recipientType - The Salesforce.com object receiving the email.

relatedToType - The Salesforce.com object from which the template retrieves merge field data. Valid objects: objects that have a standard controller, including custom objects Visualforce supports.

Refer messaging:emailTemplate for more information.

2
  • Thank you for the reply but it is not working for me. Rep profile user Role and his Outstanding programs not getting Apr 16 '17 at 15:58
  • check your code and read the documentation properly. I have just given a sample. Apr 16 '17 at 15:59

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.