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
girbotgirbot 

Custom VF Email Button

I will try and explain this as well as I can...

 

Basically I am looking to create a custom button that will generate a PDF and email it to a related contact (without going through the selecting template/contact page). I have done this easily enough by following the "Quick email button" tutorial - https://sites.secure.force.com/blogs/ideaView?c=09a30000000D9xoAAC&id=087300000006tqz&returnUrl=%2Fapex%2FideaList%3Fc%3D09a30000000D9xoAAC%26category%3DFor%2BCustomer%2BService

 

Currently we use something like:

location.replace('/email/author/emailauthor.jsp?retURL=/{!object__c.Id}&p3_lkid={!Certificate__c.Id}&rtype=003&p2_lkid={!object__c.Cn_Id__c}&new_template=1&template_id=12345678910&p5=&save=1');

 

However now there is a requirement for 2 PDF templates, depending on certain criteria. Is it possible to create a VF button with the same function as the javascript option, but to include an IF statement to select the correct template depending on a picklist?

 

I get the impression from what I have read so for the IF statement isn't a issue but is VF able to replicate the "URL hacking" approach? Am I looking at building email services to achieve this?

 

Many thanks in advance for any help.

girbotgirbot

Apologies for the bump...no answers out there?

Pradeep_NavatarPradeep_Navatar

Use action attribute of ApexCommond button and create a business logic for that action attribute in Apex Class               invoke the SOQL query on email template and by using property get it on VF page to use this inside your JavaScript code.

 

Hope this helps.