2

My flow is failing to trigger due to this error:

"Sandbox Encountered unhandled fault when running process Data_com_Get_Contacts_Constraint/301J00000000idC exception by user/organization: 00DJ0000003OapW/{4} Source organization: 00DU0000000J4OM (null) Two or more items in this collection have the same ID value. Make sure each ID only appears once. caused by element : FlowRecordUpdate.Update_Collection caused by: Two or more items in this collection have the same ID value. Make sure each ID only appears once. Salesforce Error ID: 387194366-108055 (-265105789)"

My flow is trigger by a checkbox field, does a Fast Lookup on Accounts that have that field checked and saves them to a Collection Variable. I then Loop through that Collection Variable and assign fields based on certain criteria, saving them to a new Collection Variable. I then perform a Fast Update using the second Collection Variable.

I'm just testing it on one account and no others meet the criteria which means it must be adding the account multiple time to the Collection Variable. Is there a way to control for this? Shouldn't a single Loop only loop through each record once?

  • 1
    If you're collection variable is a list, change it to a set and that should solve your issue. Otherwise, you'll needd to try putting the object and it's ID into a map with the ID as the key. Since the key has to be unique, you won't have any duplicate values for the object. – crmprogdev May 8 '15 at 20:12
  • Thanks crmprogdev, but I'm not sure what you're referring to. In Visual Workflow, I can set the SObject Collection Variable's Unique Name, Description, Input/Output Type, & Object Type. I don't see where I would enact your suggestions. – Ben May 8 '15 at 21:04
1

My apologies for my comment suggesting you use a set, as you can't specify the use of a set in a Visual Workflow.

You can however use the contains operator in Decision elements to determine whether an item in a collection variable contains the exact same value as a specified variable, or whether an item in an sObject collection variable contains the same exact field values as a specified sObject variable before adding them to a collection.

You'll want to do this sort of testing before adding sObjects from one collection to another collection to avoid this issue. See Flow Design Considerations for more on this.

  • Thanks, crmprogdev! I am no longer receiving this error since implementing this solution. I'll have to keep this in mind when using collection variables in the future. – Ben May 11 '15 at 20:02

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.