Recently, I had to migrate some 36 million patient records of an NGO where the details were in the form of Contacts spreadsheet and the data needed to be migrated to the NGO’s Salesforce instance. However, it was not that simple. For manipulating and organizing data on the instance, I needed an Account record for every Contact. In simpler words, I needed to traverse in the reverse direction, in order to create an Account for the corresponding Contact, a task simple only in words!
This is where integrating Flows with Salesforce Process Builder came to my rescue.
Written by Stuti Gupta, Salesforce Developer at Eternus Solutions
The Game Plan
I decided to keep it simple: the Account Name would be the Contact’s Last Name, as both were required fields. I also finalized on using the Salesforce Process Builder to accomplish my goal, wherein I defined a process to create an Account while creating a Contact with the Name. But all was not hunky dory! I was able to create an Account for the corresponding Contact but unable to link them, i.e. the field AccountID on Contact was not updated.This is where integrating Flows with Salesforce Process Builder came to my rescue.
Creation of Account through Flows & Process Builder
Step 1
I created a Contact with Process Builder while its corresponding Account was created through Flows and linked to the contact. You can find the Flow option within Workflow & Approvals. Once you click on New Flow, a Flow Designer appears where we users create variables.Step 2
Next, I needed to create another variable named AccID to store AccountID. For replicating this, simply click on Create Record in the Palette tab, provide a name, select the Account object and give values to the field Name through the variable LName and store AccID, as shown below.Step 3
Once this is done, click on Update Record and provide the object whose fields need to be updated, along with the fields, as shown below.Step 4
Next, link both Data Palettes by dragging an arrow and set the first one as Start Element.Step 5
Finally, save the flow as Flow_Demo with AutoLaunch type and activate the flow.Integrating Flows with Process Builder
You need to integrate this flow with the Process Builder in order to update the Account ID on corresponding Contact records. This is a simple 5-step process.- Create a process named Create Contact.
- Add an object Contact and process should run on while creating the record. There is no need for adding a criteria in my scenario but you may add one if required.
- Now, add an Immediate Action if the condition is true. Select Flows as Action and provide a unique name to it.
- Add the flow Flow_demo and set the variable values.
- Activate the process and create a contact whose corresponding Account is created.
The Alternative Solutions…
There are many other ways to accomplish this scenario. You can write an Apex trigger on Contact but it requires extensive coding with handler and test classes. Another alternative is to have the Non Profit Starter Pack installed on your Salesforce instance which incurs cost.But this one’s the best because…
Using Salesforce Process Builder and Flows is an effective solution for such scenarios as you do not need to bother about syntax of codes, access rights for packages, incurring any additional costs or the code coverage of the test classes. This simple point-and-click solution is an apt illustration of Salesforce’s philosophy of solving business problems with clicks and not code.Written by Stuti Gupta, Salesforce Developer at Eternus Solutions
No comments:
Post a Comment