How To

Blink & You May Have Missed This Hidden Gem: Get Count Via Flow Assignment

I missed this Summer ’18 gem when reading through the Release Notes. I had quickly scanned the feature of setting Stages in flow. It wasn’t until MVP Stephanie Foerst mentioned this in Slack that I learned of this feature that slid under the radar.

ReleaseNotes.GIF

https://releasenotes.docs.salesforce.com/en-us/summer18/release-notes/rn_forcecom_flow_operators.htm

You can now count the number of collection items and store that number in a variable. No more needing to loop through the collection to get the record count? WHAT?!

MindBlownATT.gif

Business Case:  Addison Dogster is the system administrator at Universal Containers. Mary Markle is the Director of Operations. As part of a process Mary has asked Addison to automate, Addison needs to count the number of records in a collection.

Solution: Addison uses flow for her process automation. Within that process, she performs a fast lookup to find all the cases associated with an account. Then she needs to determine how many cases are in the collection. Prior to Summer ’18, Addison would have to loop through the cases in the collection and increment the counter variable by 1. After the Summer ’18 release, Addison can now just use the Assignment flow element and using a number variable, use the new operation “Equals Count” to the sObject Collection Variable.

FlowCollectionWithCount.GIF

View image full screen

Quick Steps:

Note: This blog post will only focus on how to set up the Assignment element to obtain the collection itemm count.

1. Within Flow (Go to Setup | Create | Workflows & Approvals | Flows in Salesforce Classic or Process Automation | Flows in Lightning Experience), create the Record Count number variable to hold the collection item count.

varRecordCount.GIF

2. Create an Assignment Flow Element to assign the count from the collection to the varRecordCount variable. Note: If your record count variable is not a number variable, the “equals count” will not show as an operator in your assignment element.

FlowAssignment.GIF

That’s it! No more loop de loops for the record count needed.

 

 

 

 

Advertisements

7 thoughts on “Blink & You May Have Missed This Hidden Gem: Get Count Via Flow Assignment

  1. I was totally trying to do this with loops… and apparently so were other people. Thanks for this little walk through!

    Like

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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s