2

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 1 - retrieve 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?

  • Why would you want to retrieve all the object records and not only the record which triggered in first place? – user28452 Jun 13 '19 at 13:20
  • Because I need to know that there's only one record meeting filter's criteria. – Przemysław Tamoń Jun 13 '19 at 16:48
3

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

| improve this answer | |
  • The above package would not install in my sandbox. I'm waiting for SF Support to find out what the error message is. – Brian Oconnell Mar 25 at 19:34
  • Brian, try taking the install url above and replacing 'login' with 'test' – Alex Edelstein Mar 26 at 0:19
  • I'm aware of that; it was something else. In any case, I was able to get the first element in a collection variable by using loops. Not very user-friendly but it gets the job done. – Brian Oconnell Apr 10 at 18:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.