Setting up Email Templates

If you want users to receive an email when they execute a ClickLink rule, you can specify an email template in the Email Template field of a ClickLink rule. See Email Template.

Tip:

If you want the email to be sent to a user other than yourself, ensure that the person who you want the email to go to runs the ClickLink Job. See Creating and Running a Job.

Note:

An email is only sent when the rule is executed from a list view or a ClickLink job.

To create a Visualforce email template that sends an email when a ClickLink rule executes:

  1. Add custom lookup fields to the ClickLink Log Line object to link back to the source records associated with the log records. See Viewing Contextual Log Information.
  2. Click YourName | Setup | Email | My Templates.
  3. Click New Template.
  4. Select Visualforce and click Next.
  5. Ensure that Unfiled Public Email Templates is selected in the Folder drop-down list.
  6. Select the Available for Use checkbox.
  7. Enter a template name.
  8. Enter a unique name for the template in the Template Unique Name field.
    Tip:

    To use the email template for a ClickLink rule, you must enter the value of this field in the Email Template field on that ClickLink rule. See Email Template.

  9. Enter an email subject.
  10. Select User from the Recipient Type drop-down list.
  11. Select ffirule__IntegrationRuleLog__c from the Related To Type drop-down list.
  12. Click Save.
  13. Click Edit Template.
  14. Clear the Email Content tab.
  15. Copy and Paste the sample email template that follows into the Email Content tab. See Sample Email Template.
  16. Replace the values shown in Bold text with your own values.
  17. Click Save.
    Note:

    The error "The value 'null' is not valid for operator '>'" may occur when you save the template. You can ignore this error.

  18. In the Email Template field of the ClickLink rule that is to use the email template, enter the Template Unique Name that you chose earlier.

Sample Email Template

A sample Visualforce template is provided:

<messaging:emailTemplate subject="Your Email Subject Text" recipientType="User" relatedToType="ffirule__IntegrationRuleLog__c"><messaging:htmlEmailBody >
<html>
<body style="font-family:Trebuchet MS, Arial, Helvetica, sans-serif;">
<apex:outputPanel rendered="{!IF(relatedTo.Errors__c == null || relatedTo.Errors__c == 0, true, false)}">
<p>Your Email Body Success Text</p>
</apex:outputPanel>
<apex:outputPanel rendered="{!IF(relatedTo.Errors__c != null && relatedTo.Errors__c > 0, true, false)}">
<p>Your Email Body Error Text</p>
<table style="width:100%;border-collapse:collapse;font-family:Trebuchet MS, Arial, Helvetica, sans-serif;">
<tr>
<th style="border:1px solid #98bf21;text-align:left;padding-top:5px;padding-bottom:4px;background-color:#A7C942;color:#fff;">Error Message</th>
<th style="border:1px solid #98bf21;text-align:left;padding-top:5px;padding-bottom:4px;background-color:#A7C942;color:#fff;">Name of Your Object Record</th>
</tr>
<apex:repeat value="{!relatedTo.ffirule__IntegrationRuleLogLineItems__r}" var="logline">
<tr>
<td style="border:1px solid #98bf21;padding:3px 7px 2px 7px;">{!logline.ffirule__Message__c}</td>
<td style="border:1px solid #98bf21;padding:3px 7px 2px 7px;"><a href="https://Instance Name of your Org for Example, na7.salesforce.com/{!logline.API Name of Custom Lookup Field to Source Relationship.Id}">{!logline.API Name of Custom Lookup Field to Source Relationship.Name}</a></td>
</tr>
</apex:repeat>
</table>
</apex:outputPanel>
</body>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>

In the sample template:

  • Bold text shows where you must enter your own value.
  • Custom lookup fields have been added to the ClickLink Log Line object to link back to the source records associated with the log records. This adds contextual information to the log records so that you can display log entries directly on the detail pages of source object records. For further information, see Viewing Contextual Log Information.