Use Case: Collection Sort To Calculate Upcoming 3 Opportunities

Today we will use this easy use case to illustrate how you can use Collection Sort element!

Lulu Mobile uses the standard Account and Opportunity object. Since each Account has many Opportunities, they want to be able to see the average amount for only the next three upcoming opportunities (by Close Date).

We can use the Collection Sort element to achieve this requirement.

Please note that if we want the numbers to calculate in real time, it will cause a lot of the capacity (Because we would need to run the flow whenever the opportunity is created, updated, deleted, and undeleted). As a result, I recommend to run this solution on demand – which is to use Screen Flow and Action.

Flow Chart (deactivate last login date)

Steps (deactivate last login date)

Screen FlowAssignmentVariable
Screen ElementGet Records

Does the solution solve your problem? If not, write us what your problem is and we will build the flow for you!

Official Salesforce Help Article On Flow

Notify of

Newest Most Voted
Inline Feedbacks
View all comments

Thank you for this tutorial..


in step 2 (Get Records) I can not see the value recordId > AccountId (it’s the AccountId I can’t seem to find in the dropdown box)

Can yo please help?


Prity sangi

Wonderful post. Is there a specific reason you used screen flow and not any other flow type or apex trigger for this above scenario?
I want to understand the cons and pros of using screen flows and apex triggers?