Pages

Wednesday, January 20, 2016

Salesforce: Getting Started with Fast Update element using Flow

Use case: business users would like easy and fast way to mass update all Opportunity Type to "New Customer" for a specific Account.

Solution: using Flow to mass update all Opportunity Type based on Account Id provided.

1. Create New Flow
Navigate to Setup | CreateWorkflow & Approvals | Flows
Click "New Flow" button to start building a flow, you will be bring into Flow Designer.

2. Add Screen "Screen Account Id"
- Name the screen
- Add a textbox field to capture Account Id input by user
- Click green arrow icon to set the screen as Start element

3. Add Fast Lookup "Get All Opty"
- Name the fast lookup element
- Query Opportunity with AccountId equal to screen input field
- Create a sObject Collection Variable, object type = Opportunity, here we name it sobjcollvarOptyToUpdate
- Make sure Id field is save to sObject Collection Variable - we need this for update process


- Connect Screen element box to Fast Lookup box, here is how it looks like at this step:


4. Add Loop element "Iterate Each Opty"
- Name the Loop element
- Loop through sObject Collection variable created
- Create a sObject Variable, object type = Opportunity, here we name it sobjvarLoopOpty
- Assign the collection into sObject Variable


- Connect Fast Lookup box to Loop box, here is how it looks like at this step:


5. Add Assignment element "Set Opty Type"
- Name the Assignment element
- Set Opportunity Type to "New Customer" in sObject Variable


- Connect Loop box to Assignment box, choose "for each value in the collection" in the loop routing option.


Here is how it looks like at this step:


6. Add another Assignment element "Copy to New Collection"
- Name the Assignment element
- Assign sObject Variable (with opportunity Type = New Customer) to a new sObject Collection variable
- Create a new sObject Collection variable, here we name it sobjcollvarOptyFinal
- Select operator = Add


- Connect previous Assignment box to this Assignment box
- Connect this Assignment box to Loop element created earlier, this is to loop next record
Here is how it looks like at this step:



7. Add Fast Update element "Update All Opty"
- Name the Fast Update element
- Use latest sObject Collection variable which contain Opportunity Type = New Customer


- Connect Fast Update box to Loop box, when loop done, the flow will continue to do mass update to all Opportunity.
Here is how it looks like at this step:


8. Add Screen "Success" & "Error"
- Success screen just to show a message that all Opportunities has been updated.



- Add another screen to show error message throw if any error occurred on Fast Update process.


- Connect Fast Update box to Success screen box, continue with drag from Fast Update box to Success screen box, it will automatically show FAULT for the link.



Done, this flow can be enhanced as Process Builder + Auto-launched Flow, example: if an Account is marked as bankrupt, all open Opportunities Stage should be change to Closed Lost.


Reference:



No comments:

Post a Comment

Page-level ad