The document describes how to create a flow that assigns cases to an auditor user based on criteria, updates the cases with an "under audit" checkbox, and assigns the cases to a record type. The flow gets all cases marked as potential liabilities, loops through them, assigns each case to the auditor user by ID, sets the "under audit" checkbox to true, collects the updated cases, and updates them. It then gets the ID for a "case under audit" record type and in a second loop, assigns that record type ID to the cases, collects them, and updates the final records.
4. When do you use a loop?
When you want to update multiple child objects using details from a parent.
◦ When the address is added to a household account, the address field will be updated on all related
contacts who don’t have an address
When you want a change to a parent object to trigger changes in multiple child objects
◦ When an account changes its record type to client, all related contacts have their record type changed to
customer.
When you want an action to “fire” based on a change to a parent
◦ An email is sent to all contacts connected to an opportunity when the opportunity status is updated.
5. The scenario
Our organization created the position of auditor to look over all cases that are potential
liabilities to see if we can improve our processes. All cases meeting these criteria need to get
assigned to the auditor. Supervisors should be able to distinguish cases under audit. The
auditor should be able to access them in an editable list view.
6. What will our loop do?
It will assign cases to a user based on their title
It will update the cases with a checkbox so supervisors can tell them apart.
It will assign cases to a record type
7. What we will have at the end
All cases that are potential liabilities will be assigned to the new user and a new record type. This user will be able to create
and edit them in a convenient list view.
8. Create a user
Make sure to make them
a service cloud user.
Make sure to use
this title
11. Begin by choosing an object
This window will immediately appear.
For the object, choose user.
Set the flow to “trigger”
when a record is created or
updated
We choose this because people’s
job titles in the real world change.
13. Create a get records element
Name it “liability test”
Get a “case”
Filter so that PotentialLiability equals Yes
14. Select the following options
As you get more comfortable with loop flows, feel free to experiment with Choose Fields and
Assign Variables—it’s a great option when you only need 1 or 2 fields from an object, and it
helps make the flow run a little faster.
Select “all records”—this will make it a
record collection
15. We use this collection variable in a loop
If you don’t see it, go back and make sure you
chose to store all records
16. Create an assignment object
Select “current item from loop across cases”
then under audit
Select “true” as the value. It will check the
“under audit” box.
17. Assign the cases to your auditor
Create a new line. Then select current item
from loop across cases ownerid
Then, select {$record.Id}
Flow “sees” records using their ID. You can’t
assign a record (i.e. user, contact) to a lookup
field without using the ID.
18. Create the collection variable
Each edited record needs to be added to a
new collection. Next, create a new collection
variable of the same type as the record (e.g.
cases) to store it.
While this isn’t strictly necessary, I do like this
practice for learning. It also helps because
there are times where you need to re-use the
first variable.
19. Adding to the collection
On the same assignment action, add another
line.
Select the “add” operator. Then, select “loop
across cases”
You may get an error or the system may try to
add a field name after {!Loop_across_cases}
Ignore it and do not include a period. Click
“outside” the box to ignore it.
20. Use an update record action to update
the records in collect cases
21. Create a new Auditor
You will need to deactivate
your old auditor if you are
doing this in a hands-on
org due to limits on
salesforce licenses
22. If the flow is working correctly, your
closed cases will look like this
23. Create A New Record Type & Support
Process
We now want to assign the accounts that were
under audit to an account record type. This
will let us see a list view of them and do inline
edits from that list view.
To do that create a case under audit support
process and record type.
24. Get the ID for this record type
Create a new get records element (I called it
recordtype under audit
25. Get the ID for this record type
Then, get a “record type” object. Make the
name equal case under audit
You can get the recordtype of any object
(custom or otherwise) this way.
26. Create a second loop right after the first
Add “collect cases” (your updated variable) to
this loop
27. What do we do next?
Assign that ID to the current item in the loop
28. What do we do next
Create a collection variable
Start a new line and add things to it!
29. Add records
Replace the variable in your old update record
element with WithID
Debug and see what happens! All the changes
get passed!
30. The final flow
looks like this
Now activate it.
If you want to re-run the flow, make a new
auditor or give your employee a new title,
then switch it back to auditor.
My background is a teacher—math teacher. We make you work. What we won’t do is use a screen flow. Screen flows are great, but they discourage you from using recorded’s
Ask the group. Also ask for an example of each.
I don’t want to focus on the goal here, but it’s worth mentioning because loops aren’t used for the same reasons they used to be used.
I picked this because this is something I have to do a lot. Loops help you react to changes in how your org works.
Switch at this point. Ask what kind of flow should we make.
Ask what kind of object will trigger it. When should it trigger?
Ask about entry conditions. SAVE AND DEBUG CONSTANTLY.
Anybody have any ideas. We want to get all the opportunities for our new employee.