Process Builder & InvocableMethod- Alternative to send Visualforce as an email attachment from Apex Trigger
Previously I had written same blog post and it was working fine before Winter 16. However, after Winter 16 critical update was released by Salesforce to consider getContent() method as a callout. If this update is enabled in your Salesforce instance then my previous blog post will not work.
In this blog post, we will go through alternate design, where we would still be able to send Visualforce page content as an Email attachment. Difference is, instead of Apex Trigger , Invocable Method and Process builder will help us getting there.
Again, consider below simple Visualforce page, which we want to send as an attachment.
Summer 16 release of Salesforce brings festival of lights not only in its logo but to Process builder as well
Before going to this feature, lets try to outline problem first. Consider a situation where we need to create a task when lead source is Email and send an email to owner if lead source is Email and company name as ABC.
If we try to solve it using process builder, very soon we will understand that it is not possible in one process builder. Process builder can have only one criteria with true and false condition. In previous process builder, we could either perform action if lead source is Email or lead source is Email and company ABC. There is no way to define new criteria which will run along with previous criteria as shown in below image.
Consideration before using Trigger, Workflow and Process builder field update at same time in Salesforce
Workflow rule and Process builder are the tools because of which Salesforce Admins can perform so many tasks, which were only possible by writing Triggers. Before release of Process builder, if we wanted to perform field update on child records or post chatter messages or auto execute Visual Flow, Triggers were used by developers.
As a best practice in Salesforce, it is always suggested that we should prefer “point and clicks” over code. Indirectly, prefer Workflow rule or Process builder over Triggers.