I have a problem where my nested For each
actions are creating duplicates, and I am not sure how to correct it.
Scenario:
From system 1 we have multiple images coming into the Logic App. It needs to add them onto a record in D365 that can have multiple images already. I'm trying to set up the Logic App so that it will check the images on D365 and only add an image if that image doesn't already exist.
Example of how the images in the http trigger come in- enter image description here
Issue:
I have tried having a For each
action for the images on D365 nested in the For each
for the images from system 1, but this created duplicates on D365.
Summary of what happens:
I have also tried swapping it around so the For each
action for the images from system1 is nested in the For each
for the images on D365, but it also creates duplicates on D365.
Summary of what happens:
Any ideas would be appreciated!
Split your Logic App workflow into two logical parts:
Your question doesn't clarify how exactly multiple images are coming into the Logic App and how you are checking if they exist in D365.
If you have a container with images coming into the Logic App and another container with images that already exist in D365, you can easily generate a new container with the items that exist in the first container but not in the second. You can use collection functions such as contains
or intersection
; you can also use the Filter array
action - depending on your needs and the format in which you receive the data.
In the second part of your Logic App, use a new For each
action to add all images from the result container to the record in D365.