Friday, 23 November 2012

Sending Document as an attachment in the form of Pdf Using Workflow Rules of force.com platform and Visualforce Template feature


Emailing the pdf on click of a boolean check box or click of a button are frequent requirements for which we often think of using Triggers and using Outbound Emails of apex .

This requirement can be easily accomplished through workflow rules and the Visualforce Email Templates

In this blog POST will walk through on how to approach this

Step 1:
Creation of Email Field This is the first step to create an Email Field so that when we develop workflow rules when for the email alert the Recipient Type is asked we may fill in the email field
Step 2:
Creation of workflowThis is a simple step where based on business criteria draft a workflow rule.Usually rule should be to trigger the email alert only if the boolean flag is checked .
Step 3:Creation of email template The email Template will be a visualforce template and hence if you are familiar with visualforce this must be a straight forward impementation
Below is the sample code that you may customize by replacing with your relevant object name



   
   Please find your  receipt attached with this mail.
   


 


  
    



<!-- Section to insert header-

{!$Label.Header}

Label1 Label 2 Label 3

Image From Notes and Attachment


If have any image to display from documents then you will have to use the following
https://AAA.salesforce.com/servlet/servlet. ImageServer?id=BBB&oid=CCC AAA = your SFDC server, found in the URL of any SFDC link after you log in BBB = the record ID of your publicly available document CCC = your organization ID You can pull from documents.Dont pull from static Resource .It never works .
I answered couple of questions in stackexchange recently and this promoted me to write this blog post so that may help .

http://salesforce.stackexchange.com/questions/4637/is-it-possible-to-have-html-in-a-visual-force-email-template/4639#4639

http://salesforce.stackexchange.com/questions/4641/is-is-possible-to-display-an-image-or-icon-in-a-email-using-a-visualforce-templa/4643#4643

Introducing Lightning Base Components

Lightning Base Components are great addition to the platform and in fact revolutionary .One of the concerns around lightning component ...