[SalesForce] Flow – How to retrieve first value of a collection variable

I have to use an Autolaunched Flow to automate the following task:

  1. Retrieve all the certain object's records which meet a certain criteria.
  2. If the size of the collection is 1 – assign some field values from the only record to the one which originally triggered the flow.

The only idea I came up with:

  1. Retrieve records to the collection variable.
  2. Iterate through this collection and with every loop count increment the sizeCounter (default set to 0) variable
  3. If the size variable equals to 1retrieve records again, but now put only "the first one" to the new, single record variable

Looks like a very poor solution but I can't find any alternative. Is anyone aware of a better way to solve this problem?

Best Answer

As of Spring '20, you can use the GetFirst action in the CollectionProcessors package.