function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
kdmrkdmr 

Use Visual force template in workflow(Email Alert)

Hi,

 

 I would like to send a mail to  a contact when case is created.The Email contains list of cases related to account.

So i created workflow with condition(case status = new) and type is Email Alert.

 

It is working  fine when I send it from a Send Email button on a Contact detail. When trying from work flow,its sends the mail but doesn't populate any  values.

 

Code as below

<messaging:emailTemplate recipientType="Contact"  relatedToType="Account"
    subject="Case report for Account: {!relatedTo.name}">
<messaging:htmlEmailBody >
  
        <html>
            <body>
               <p>Dear {!recipient.name},</p>
               <p>Below is a list of cases related to the account: {!relatedTo.name}.</p>
         <table border="0" >
                 <tr >
                     <th>Action</th><th>Case Number</th><th>Subject</th><th>Creator Email</th><th>Status</th>
                  </tr>

                  <apex:repeat var="cx" value="{!relatedTo.Cases}">
       <tr>
           <td><a href="https://na1.salesforce.com/{!cx.id}">View</a> | 
           <a href="https://na1.salesforce.com/{!cx.id}/e">Edit</a></td>
           <td>{!cx.CaseNumber}</td>
           <td>{!cx.Subject}</td>
           <td>{!cx.Contact.email}</td>
           <td>{!cx.Status}</td>
       </tr>
    </apex:repeat>    
        </table>
    <p/>
    <center>
        <apex:outputLink value="http://www.salesforce.com">
        For more detailed information login to Salesforce.com
    </apex:outputLink>
</center>
</body>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>

 

Thanks for any help

 

 

 

 

 

shillyershillyer

When defining the Email Alert, try making the Recipient Type = Related Contact. And then make Selected Recipients = Related Contact: Contact Name.

 

Hope that helps,

Sati

kdmrkdmr

Thanks for reply

 

Actually workflow sent the mail to contact but problem is , no data are showing in the email.i got mail(used above code i mentioned) and i paste here for your reference

 

Dear ,

Below is a list of cases related to the account: .

ActionCase NumberSubjectCreator EmailStatus
For more detailed information login to Salesforce.com   
 
 
Can you anbody help me how to get the list (cases list for the contact) by using workflow email alert?
 
Thanks for any help
   

 

 

 

 

 

 

 

kdmrkdmr

Can you anybody give the solution?

 

Thanks for any help

 

RajaramRajaram

The VF seems to work against the Account object. If you want to run this in the context of a case, you need to make sure the relatedTo is set to the case object, relatedToType="Case" to be specific.

 

If you want to refer the Account associated with the case, you can get to it by using relatedTo.Account.Name etc.

 

Hope this helps..

 

 

elyb527elyb527

I also have a VF Template that gets sent from a workflow.  It is working correcty as far as fields go.  When I test the template from the Case using Send an Email it looks great.  My client says that when he gets one sent by the workflow, it isn't formatted nicely. 

 

I am thinking the workflow sends the plain text version rather than the HTML version.

 

How do I manage that?

 

Thanks

PaulMacPaulMac

kdmr,

 

Did you ever get this working? I want to send a contact a list of their open cases, say every Friday morning. Not sure if this is possible.

 

thanks!

PaulMacPaulMac

I was able to use a where clause to get "open" cases (see below). Now I'm just wondering if it's possible to send emails on a scheduled basis (e.g. Every Friday at 9am)

 

<apex:repeat var="cx" value="{!relatedTo.Cases}">
       <apex:outputPanel rendered="{!cx.IsClosed= FALSE}">
           <tr>
               <td>{!cx.CaseNumber}</td>
               <td>{!cx.Subject}</td>
               <td>{!cx.Phase__c}</td>
               <td>{!cx.Type}</td>
               <td>{!cx.Status}</td>
               <td>{!cx.CreatedDate}</td>
               <td>{!cx.Owner.Name}</td>
           </tr>
       </apex:outputPanel>
    </apex:repeat>     
 

Geetha28Geetha28

If you got it working,please send the steps to follow.Because i am in the same position.When i tested in the preview mail works fine,but triggered from workflow empty data list,basically id not passing .

 

Thanks in advance.

Keith Weaver 8Keith Weaver 8
I also am having the same issue.  You have a visualforce email 
<messaging:emailTemplate subject="Redfin Partner Program - We're almost ready to go live!" recipientType="Contact" relatedToType="SFDC_Candidate__c">
<messaging:htmlEmailBody >
<p><span style="font-family: helvetica;">Hi {!recipient.Name},</span></p>
<p><span style="font-family: helvetica;">Thank you for taking time to interview to be part of the Redfin partner program. We are excited to move forward with your application.</span></p

Looks great when I look at the email preview but does not include the merge fields when I send it using an email alert.  Please help!