Let's Use Lightning Process Builder
I’d like to go over the Lightning Process Builder which was released in Spring ’15. It is close to, feature-wise, what Apex Triggers can do but you just do everything with configuration settings (no coding).
Let’s create an active process so that, when the address of the Contact object is edited, it will update the Account’s address. The ProcessBuilder’s settings page can be found from Setting–>Create–>Workflow and Approvals–>ProcessBuilder. An Aura (Lightning) based page will show up. Click New to start.
Enter the Process Name, API Name, and a description. Then click Save.
The process settings page will show. Let’s set the following:
Target Object for the process
Criteria to execute the action. *Scheduling is also available
The setting page is in a flow chart. The actions will be conducted in a waterfall flow.
Set Target Object
Set the target Object and select the trigger to start the processing. You can choose from “Only when a record is created” or “When a record is created or edited”. To set the trigger when the data is just edited, select “When a record is created or edited” and execute the action “create date ≠ last update”. Click Save to proceed.
Next, let’s set the criteria to execute the action. A calculation setting is available; however, let’s stick with the standard-setting this time. So, I want to execute this process when an address is edited. To do so, select the operator as “is edited = True”.
Actions that can be defined are selected from below:
Create A Record
FlowPost to Chatter
Submit For Approvals
I am surprised that they support “Submit For Approvals”. In order to update every contact address that is linked to the account record, select “update record” and select the child-relation name (Contacts) for the record type.
*If you would like to update a specific record, you can set the criteria under “Update Records”.
*Records that are related between different Objects (Reference or Parent-Child) can be updated.
Now, the setting is complete. Click “Activate” to start the process.
One of the outstanding features of the ProcessBuilder is the version control of the process. Only one version can be activated within one process. This will help the developers to quickly switch back to the previous version if they made an error in the editing process. I think the concept of having a version control is rare to find in a Salesforce environment but very helpful.
Watch Out For Restrictions
Just like Workflow and VisualWorkFlow features, please check the Help reference and be aware of the usage restrictions. The idea is the same as automatic update features (e.g. Workflows and Triggers). I would advise you not to set the process as unconditional updates for all records or have the workflow/process/trigger work in a chain of events.
As of today, the data sync processing, like the one I have introduced in this blog, cannot handle more than 101 records at once. It will give you a governor limit warning with the message – “Too many SOQL queries: 101″. The ProcessBuilder is such an effective feature; I hope they will improve this over time.
The ProcessBuilder had new update releases in Summer ’15. This feature is going to be one of the exciting features to keep an eye on. LightningProcessBuilder feature updates:
Able to use Multiple Select lists in many sections
Easy maintenance of the version control. You do not have to wait 12 hours to delete the saved process.
I am interested in finding out if ProcessBuilder is capable of replacing ApexTriggers. I look forward to sharing that information with you.