Till now we have discussed Create a Record, Time-dependent action and Update records using the Process Builder. In this article, I am going to discuss another business scenario where you can use Process builder i.e. Clone a record. Process Builder runs in the system mode and Flow runs in user mode. Let’s start with a business use case
Business Use case
Steve Cartwright is working as a System administrator at Universal Containers (UC). He has received a requirement to auto create a new Opportunity (Similar to an old record) whenever an Opportunity is successfully closed and set the Close date for new Opportunity to 120 days from old opportunity’s close date.
Solution for the above business requirement
There are multiple solutions possible for the above business scenario. You can either use Apex trigger, a combination of Flow and Process Builder, and few more. We will use Process Builder to solve the above business requirement. This is just one level cloning, if you want to implement deep clone (Multilevel cloning) then you have to use Flow or Apex code. This article will help you to understand the way to clone a record using Process Builder and concept to use dynamic date in the Process Builder. Follow the below instructions to create a Process for the above business requirement
1. Unlike Workflow rule, Process builder doesn’t allow you to use dynamic date on a field update (i.e. Update Records action). For this we have to create a custom formula field 120 After RCD on Opportunity object as shown in the following screenshot
2. Also creates a check-box field One time activity (Default value: – Unchecked), so that Process will fire only once, after successful closure of an Opportunity.
3. To create a Process click on Name | Setup | App Setup | Create | Workflows & Approvals | Process Builder. Click on the New Button available on Process Management page, A popup will open where you have to enter a Name (Enter Clone an opportunity as name), API Name and Description as shown in the below screenshot
5. Once you click on the Save button, it will redirect you to Process canvas. Click on Object node to add object, Select Opportunity object, in this case and set the evaluation criteria, Please refer to the following screenshot for more details
6. The next step is to define the Process Criteria. For this click on Add Criteria node, Enter Criteria Name, Set filter conditions (Similar to Rule Criteria in WFR), as shown in the following screenshot
7. Now we have to add an immediate action into the Process to create an opportunity record. For this use Create a Record action, Please refer to the following screenshot for more details
Make sure that you have assigned data in the correct format, because Process builder obey Validation rule. If some fields are required by using Validation rule, then make sure that you have added those fields. Same time if some fields are required using Page layout, you can ignore those fields.
8. Next step is to update the One time activity field to True, so Process will not fire if a user is trying to update the Closed Opportunity. For this use Update Records action, Please refer to the following screenshot for more details
9. Final task is to activate your Process by clicking on the Activate button.
Now onwards if the user will update the Opportunity stage to Closed won, Process builder will automatically create a new Opportunity.
16 thoughts on “Getting Started with Process Builder – Part 3 (Automatically Clone a Record if it Meets Certain Criteria)”
notsoloud
So it is not truly a clone, but just a creation of a new Opportunity. Same with a Flow, if you want a true clone you’ll have to list out all the fields you want included in Step 7?
Rakesh Gupta
Yes, you are correct. Use SObject collection variable to copy multiple records.
Keri Callison
Thank you so much for this post. I’ve used it to change the record type on a cloned custom object. I was able to change the Record Type field, but how can I make other field “re-set” to blank? I thought it would be $GlobalConstant.Null, but that is incorrect. Thank you for you help!
Rakesh Gupta
You have few options
Sutha
Thank you!
Sutha
This is great!! Only questions – when I try this, the cloned opp does not take the Account name, is there anything I have to do differently to accomplish that?
Rakesh Gupta
Go to the step 7# and also add AccountId field
Sudipta Deb
Rakesh –
I think now we can clone the Opportunity and set the closed date on the cloned opportunity by using formula : [Opportunity].CloseDate + 120. No need to create any additional field in Opportunity object. The above use case I have tried on my developer org without using any additional field and it is working fine now.
Regards,
Sudipta Deb
Rakesh Gupta
Correct but only after Summer’15 release not prior to that.
pkeane2014
Rakesh,
Thank, great articles. Regarding multilevel cloning in process builder, could I use multiple sequential time initiated clones, with a counter field, to stop the sequencing when needed, to effect the result of multilevel cloning in apex?
Thanks
Pete
Brian Newbold
Rakesh, when creating a record can you merge text+field data?
For example in your step 7. is it possible to push a value into a field such as:
” The close date is: [Opportunity].X120_After_RCD__c ”
I tried the usual notation with curly braces like: {!Opportunity.X120_After_RCD__c}
but got an invalid reference error and couldn’t save.
TIA
Brian
Rakesh Gupta
Yes after summer’15 release, you can now update fields using formulas and date functions
http://releasenotes.docs.salesforce.com/en-us/summer15/release-notes/rn_forcecom_process_formulas_update_fields.htm#rn_forcecom_process_formulas_update_fields
Brooks
Thanks, Rakesh! Question on Step 7 – why is the fourth field for “Set Object Variables” a picklist of fields, i.e “Forecast Category”, etc.?
Best.
Brooks
Rakesh Gupta
To set the “Forecast Category”
jagjeet
Good one. I have some doubts around “one time activity” field. Can’t we just avoid it and have an evaluation criteria which says execute only if the stage is changed to “closed won”?
Rakesh Gupta
No because currently ISCHANGED function is not supported by Process builder