You need to sign in to do that
Don't have an account?
Comparing Flow Sobject Collections and Removing Dupes
Hello all,
I have a Custom Metadata type that stores records that are equivalent to "Tasks" and contains a few fields that hold criteria text for when these tasks should be created.
In my Flow, I have a Get request for all Metadata records that match the input criteria, and then I loop through those Metadata records and assign each to a Task sObject variable and add them to a collection of Tasks for insert. I include the Metadata Id field on a task field when I insert them. This all works well.
The issue happens when I try to remove duplicate values from the Metadata because the Tasks are ALREADY EXISTING...
Here is what I tried to do:
However, the Remove All assignment node is not removing the sObjects from the NewMetadata collection as I would anticipate.
Can anyone please help?
Thanks,
Adam
I have a Custom Metadata type that stores records that are equivalent to "Tasks" and contains a few fields that hold criteria text for when these tasks should be created.
In my Flow, I have a Get request for all Metadata records that match the input criteria, and then I loop through those Metadata records and assign each to a Task sObject variable and add them to a collection of Tasks for insert. I include the Metadata Id field on a task field when I insert them. This all works well.
The issue happens when I try to remove duplicate values from the Metadata because the Tasks are ALREADY EXISTING...
Here is what I tried to do:
- Find all the existing Tasks on object
- Get all Tasks
- Add to sObject Record Collection Variable (ExistingTasks) and capture Task Field "Metadata_Id__c" which = the SF Id of the Metadata
- Loop through ExistingTasks to get collection
- Each record is called ThisExistingTask
- Assign ThisExistingTask.Metadata_Id__c to a sObject Record Variable called ThisMetadata
- Add ThisMetadata record to a sObject Metadata record collection variable called ExistingMetadata
- Use the input criteria to Get the new Metadata
- Get Metadata records that meet the input criteria
- Add these to a Collection callend NewMetadata
- Loop through ExistingMetadata collection to remove from NewMetadata
- For each record in ExistingMetadata collection called ThisExistingMetadata
- Use an Assignment node to "Remove All" ThisExistingMetadata from collection NewMetadata
- //do more stuff
However, the Remove All assignment node is not removing the sObjects from the NewMetadata collection as I would anticipate.
Can anyone please help?
Thanks,
Adam
Did you end up figuring this out?? Having the exact same issue right now.
Hi Trina,
I did not find a way to do this with a flow loop.
I ended up making an invocable apex call in the flow that would upsert the tasks based on a unique identifier. That way the dml handles the duplicate existing tasks for me.
hope this helps!
thanks,
Adam