Salesforce Auto Launched Flows – Who needs code?!

Loop through an auto launched flow without using the loop element

In this example I will be cloning an Opportunity with all related products in an auto launched flow without using the loop element!
You can trigger the flow you are about to create in one of three ways:
1) URL button
2)Lightning Process builder
3)Embed flow in a VisualForce page and trigger via a button

First, you will need to create a checkbox on the Opportunity Product (Default False). We will use this as our loop criteria if you like and will allow us to update this checkbox and process all Opportunity Products.

1) Record Lookup– If you are choosing options 2 or 3, you can skip this step and assign variables in your flow certain values. If you are using method 1, you will need to look up the current Opportunity you wish to clone you can then obtain all info needed to create your new Opportunity. Store each field you wish to use as a separate variables.

2) Record Create– You will then need to create the new Opportunity. For this, you simply insert your variable values from step 1 into these fields on your new opportunity. Ensure you give this Opportunity a unique Variable to reference later on in your flow. Like this:
salesforce auto launched flows record create Salesforce Auto Launched Flows   Who needs code?!

3) Record Lookup– This is where you need to look-up any Opportunity products from your initial Opportunity which is going to be cloned. You will need to add the criteria of the checkbox you created earlier to equal false. This is so that we can update this field to True after we have created the clone of this Opp Product for your new Opportunity.
salesforce auto launched flows record lookup Salesforce Auto Launched Flows   Who needs code?!
4) Record Create– Create the New Opportunity Products. Insert your new Opportunity ID variable in to the OpportunityID lookup field on the Opportunity record. This will create the relationship between your new Opportunity and this new Opportunity Products.

5) Record Update– Update the old Opportunity Product with a check box equalling true. This will then eliminate this Opp Product from the cycle as we have already just created the clone of this Opp product.

6) Record Lookup– Repeat step 3. Lookup the Opportunity Products with the following criteria. Checkbox equals false. This will only look for opportunity products which have not been already updated. Assign this new Opp Product a new unique variable for the ID.
salesforce auto launched flows record lookup 2 Salesforce Auto Launched Flows   Who needs code?!

7) Decision– Create a decision which will determine if there are any more Opportunity Products to be created and added to your new Opportunity. The Decision will look at your step 7 variable ({!id}) and determine if it is true or false. If it is false, you want this to then go on to step 3 and repeat the whole process again. Your Decision does not need another branch. If the criteria is not met then your flow will simply end!
Your flow should look something like this – Enjoy!
salesforce auto launched flows decisions Salesforce Auto Launched Flows   Who needs code?!

Resource : cloudsocius

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s