I have an issue with the following flow : enter image description here

I have a field source on contacts populated automatically by an external Id.

Partnership is a custom object on which I can set another source field. When this field is set, I want to go through all contacts that already have the same source and get their Account Ids.

Then I create records in a junction object "Partnership_account" with Account Ids and Partnership Id so I know how many accounts each partnership brought.

My flow is technically working but it often makes more that 101 queries (if there are more than 101 contacts with this source).

I think I can avoid that by removing decision and loop elements and use a mass create instead. In order to use the mass create element, I think I need to populate a collection variable based on Partnership_account object and populated with : accountId1, partnershipId1, accountId2, partnershipId1, accountId3, partnershipId1, etc.

Problem is that I can't think about a solution to populate this collection variable... Does anyone has any clue ?

If my case is not clear, I can also add more details.

Have a nice day !

  • 1
    Avoid Data elements (like Get, Create, Update) within Loop element. Instead add the Loop variable to Collection Variables (one to create,one to update) using Assignment and after last item, use update and create elements on respective collection variable. Nov 1 '19 at 7:10

You don't want to do Get Records and Update Records within a loop. Instead, you have to loop through your contacts and assign each ID to a collection variable. When that is done, you do the Get Records using the ID collection var and assign each contact to an Contact collection var.

Then you loop through the Contact collection, assign the desired values to an Account single var, and add that single var to a Partnership Account collection var. When that's done, you do the Create Records using the Partnership Account collection var.

  • Hello David, Thanks for your advises on this case. It's really clear for the first part on how avoiding gets and updates in the loop. However, at the end, I don't want to update accounts but mass create records in a custom object (partnership_account) that has two fields : AccountId & PartnershipId. If I follow your flow, I'm finishing with an Account Collection Variable that contains a list of account ids. I would like to finish with a partnership_account Collection variable containing both account ids and partnership id. Do you know how I could do that ? Not sure I'm clear :/ Nov 6 '19 at 17:19
  • 1
    Sorry, I edited my answer to use the Partnership Account object and the Create Records action. Nov 6 '19 at 17:46
  • Thank you David ! I succeeded to make my flow run. Nov 7 '19 at 11:00

Also used this article to better understand fast create : https://salesforcesidekick.com/2015/08/24/how-to-use-a-fast-create/

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.