Deep Clone through Visual Workflow



In Salesforce Cloning is the process of creating records with the same details. Salesforce provides the out-of-box feature to clone object records. It’s a way to create record with similar data and save your precious time. Now I am coming to the point, if some one say’s that they want to clone account with opportunity then you will first think about apex Trigger but no there are other ways this.e Visual Workflow. In this article I will demonstrate how efficiently you develop a deep clone feature for your org.
Business Use case :- Business users in Universal container want a way to clone account with opportunity (Only closed won) and set Close date on the new opportunity to today plus 15days. They have only one closed -won opportunity on each account.
Solution of above business requirement
I took above example only for demo purpose. It may possible your organization maintaining accounts in different ways as mentioned in above business use case. In this blog I will use Visual workflow to solve above business requirement. First of all list down all fields that required to create an account and opportunity, for me to create an account and opportunity it’s required below fields it may vary based upon the custom validation rule
Account
Opportunity
Name
Name
Employee
Stage
Phone
Close Date
Account Name
 To develop add functionality follow the below instructions
  • Click on Name | Setup | App Setup | Create | Workflows & Approvals | Flows
  • Click on New Flow, it will open flow canvas for you
  • First create a variable with name AccountID to pass account ID, create variable for all fields as shown in below screenshot. In CloseDate variable set default value is {!$Flow.CurrentDate} it means today’s date

  • Drag and drop a Record Lookup ( Give the name Account Clone) on the window, to save account field values in variables that you created, as shown in below screenshot

  • Likewise drag and drop another Record Lookup ( Give the name Opp Clone) on the window, to save opportunity field values in variables as shown in below screenshot

The next task is increment  CloseDate variable by 15days, to do this drag and drop an Assignment(Give the name Increment date by 15 days) on the window, and add 15 days as shown in below screenshot

  • Now we will create account record first, to do this drag and drop another Record Create ( Give the name Craete new account) on the window, pass the variable values in the fields and store new account id in a variable in my case it’s  NewAccountID as shown in below screenshot

  • Final steps creates opportunity record. to do this drag and drop another Record Create ( Give the name Create opp) on the window, pass the variable values in the fields. In the AccountId field pass the newly created account id i.e. NewAccountID and select Stage as per your choice, as shown in below screenshot

Finally our flow will look like below screen shot

Save the flow and close the canvas.
It’s time to test this feature
To test this feature you have to create a button on Opportunity to invoke this flow, to do that follow the below instruction
1) Click on Name | Setup | App Setup | Create | Workflow & Approvals | Flow
2) Click on your flow name and go to the detail page and copy URL link
3) Now create a detail page button on Account object and pass  Account id to variable AccountID , same as below screen shot

4) Now go to any account record that have one opportunity with status “Closed won“and click on custom button that you created on last step and see the magic.
Note:- In this demo I used only few fields but you can take as many as fields you want but you have to maintain same number of variables in flow. You can also add check what happen when account does not contains any opportunity.

Post a Comment

MKRdezign

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget