0

So I'm new to using flow and i'm doing something wrong. Hoping someone could help to get me on the correct path.

I have a very simply flow that I'm trying to do that involves pulling a record collection from the Subscription object and creating a new record for each record in the collection in a custom object called Entitlements using only 4 of the data points.

My preference is to have the bulk create work and not have to loop through, but I cant seem to get that to work so I tried looping through and creating the records within the loop, but that does not seem to work either.

Here is what is currently setup with the loop. When I run, I do not get an error, but the records are not being created. The fields I'm trying to include are:

  • Account ID (Destination field is Lookup)
  • Contract Number (Destination field is Text)
  • Product Name (Destination field is Text)
  • Product ID (Destination field is Text)

Any help is massively appreciated

enter image description here

  • Ahhh I got the loop working. It was a simple mistake of assigning the incorrect Record collection. – Shawn M May 15 at 20:59
  • You want to avoid creating records in a loop. In the loop use a second assignment to add the variable to a collection, and then once the loop finishes use a create records element to insert the full collection in one step. This will bulkify better. – gorav May 17 at 14:30
  • Paste your debug log here, please. What does it say? – Andy E Utkan May 18 at 2:08
2

Avoid creating records inside a loop. It might fail if there are too many records. Also, it's not the best practice.

You can create a record variable of type 'Entitlement', assign the field's values for Entitlement record inside the loop, and add this variable to the Entitlement record collection variable.

Use a single 'Create Records' element after the loop and insert the Entitlement record collection variable.

Edit

Adding an example:

enter image description here enter image description here enter image description here enter image description here enter image description here

| improve this answer | |
  • How do you add add the record variable to a collection? This is the part I'm struggling with. I'm guessing a second assignment where I set the the Variable as the Collection, Operator as Add, and the value as the Record.field? – Shawn M May 18 at 18:39
  • Yes. I have added an example for your reference. – Prakhar Saxena May 19 at 5:13
  • 1
    You are the man. This helped. My flow is now working. No more creating within the loop. – Shawn M May 19 at 16:56

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.