Using Inline Visualforce Page and Auto Launched Flows to Trigger Actions on Unsupported (By Process Builder and Apex trigger) Objects

You are currently viewing Using Inline Visualforce Page and Auto Launched Flows to Trigger Actions on Unsupported (By Process Builder and Apex trigger) Objects

We all know how Process Builder and Apex triggers aren’t supported on certain objects like Partners, Contact Roles, Permission Set Assignment, Quote Documents and many others. So if someone were to add a record to any of these objects and an action was supposed to be triggered based on this addition or manipulation, that won’t be possible to build via Process Builder or an Apex Trigger. But hey, we all are also very well aware that nothing is impossible on this powerful Force.com platform so there is obviously a solution to this conundrum.

Mission Requirement: Wayne Enterprises wants to ensure that a Quote is not submitted for approval without at least one Quote PDF attached to it. If there is no Quote PDF attached to the Quote, the user should not be allowed to submit the Quote record for approval.

Mission Strategy: Bruce Wayne takes it upon himself to accomplish this mission and decides to use an Inline Visualforce page along with an Auto Launched Flow to do this. The Inline VF page will be used to launch a Flow every time a Quote PDF is added or removed from the Quote record and the Flow will perform the heavy lifting of counting the number of Quote PDF attachments and then updating a Count field on the Quote record. This field can then be used in the Entry criteria of the Approval Process to ensure that a Quote is not submitted for approval without having at least one Quote PDF attached to it.

Solution: The two key pieces here as described above are the Inline Visualforce page and our Auto launched Flows (oh I love them!).

  1. Auto Launched Flow

    Flow

     

    Full View

     

    Fast Lookup to store all Quote PDF’s in an SObject Collection Variable

     

    Decision Element to check for null or non null Quote PDF’s
    Loop through Quote PDF Collection variable
    Increment PDF Count by 1 for each Quote PDF found

     

    Update Quote Record with Count of Quote PDF’s
  2. Inline VF Page

As a final step , add the inline VF page to the Quote page layout  like this:

Inline VF page added to the Quote page layout

 

Now add or delete a Quote PDF on the Quote record and see the magic happen:

Voila!

Inline VF pages coupled with Flows is a powerful feature and I recommend that you think about using Flows first before you get into the world of Apex controllers.

Happy Flow’ing!