0

How can I not create duplicates with my flow? I want to create records from List A into List B IF they don't already exist in B, if they already exit, DO NOT create them, as it is creating duplicates.

I've added the condition to check if item exists and then if it exists do not write:

length(outputs('Get_Items')?['body/value'])

However this does not work and does not create any records even if the list is empty.

Filter query:

Center eq 1463 and (AutomationType eq 'Management Reporting' or AutomationType eq 'Testing') and Repeatable eq 'Yes'. 

all these values are from list A.

Any help would be appreciated.

enter image description here

enter image description here

possible change: enter image description here

5
  • Again, you're not showing exactly what your filter criteria are. THAT is what is where the problem is with the query, so it returns 0 items. And then your flow happily creates the new item. What are your filter conditions in words, and how are you writing them in the box, EXACTLY??
    – teylyn
    Dec 22, 2022 at 22:35
  • added that in..
    – Jonnyboi
    Dec 22, 2022 at 23:36
  • You are using "Manually trigger a flow" trigger. What is your requirement? Do you want to create item in List B whenever any item is created/modified in "List A" OR whenever you click on the button, you want to read items in list A and then create items in list B based on items in list A? Dec 23, 2022 at 10:40
  • Ideally i would like to create item in List B whenever it is created in List A.
    – Jonnyboi
    Dec 23, 2022 at 14:44
  • Then you don't need to use manually triggered flow and get items action for List A. You have to use the "When an item is created" trigger for list A and get items action for list b Dec 23, 2022 at 15:38

2 Answers 2

1

As you want to create items in List B based on items in List A, you have to check the length condition based on items in List B (not List A).

So, before using Create item action, you have to get the list items from list B for specific filter condition. Then based on items returned, you can check length of decide if you want to create item or not.

Here's example for this:

enter image description here

enter image description here

You have to do this for each item in List A.


Update from comments:

Here is the full flow configuration which should work for your requirements:

enter image description here

5
  • ah so i have to create a 2nd get items for list B? My current one is for list A
    – Jonnyboi
    Dec 23, 2022 at 15:17
  • ive updated my scnreeshots above
    – Jonnyboi
    Dec 23, 2022 at 15:22
  • Check updated answer for complete flow which should work for your requirements. Dec 23, 2022 at 16:04
  • Thank ganesh, but how to include my filtering of List A, Center eq 1463 and (AutomationType eq 'Management Reporting' or AutomationType eq 'Testing') and Repeatable eq 'Yes'.
    – Jonnyboi
    Dec 23, 2022 at 16:43
  • You want to create item in list B only when above condition met in list A (When above values are selected for respective columns when item is created in list A)? Dec 23, 2022 at 17:01
0

If Request_ID is a parameter passed from the flow trigger, you cannot just use Request_ID, because you need the context of the trigger.

I suggest you initialise a variable varRequestID, set it to the trigger parameter value and then use the variable in the filter query. Note that you must wrap the variable in single quotes, too!!

Here is the screenshot:

enter image description here

Of course you can directly use the dynamic content reference in the Filter Query, but if you go via a variable, you can more easily inspect it in the flow run.

Screenshot of direct reference. Note the single quotes around the request id property!!

enter image description here

6
  • If that resolved your issue, please mark the answer as described in the tour. If it didn't, please leave a comment, so I can follow up.
    – teylyn
    Dec 22, 2022 at 20:01
  • so to run it I have to input a request ID? Is there a way I can just run it and not create duplicate values? When I run manually it asks for an input.
    – Jonnyboi
    Dec 22, 2022 at 20:58
  • Your question does not show where the Request_ID is coming from. I assumed it was a parameter for the workflow trigger. If that is not the case, then please explain what Request_ID is and what its value is. Or is the text "Request_ID" the words in the title???? It's hard to help you with a query filter if you black out what you are actually putting into it.
    – teylyn
    Dec 22, 2022 at 21:34
  • Sorry - i do not use Request ID .. That was when I had another Get Items in my flow for List A. I dont think I need Request ID. What else can be done if I forget about Request ID?
    – Jonnyboi
    Dec 22, 2022 at 21:44
  • Are you messing with me? Read your question. Maybe it's time you edited your question and ask what you REALLY want to know. Or do you want to keep us guessing? Please use your words and explain what you want to achieve. Don't use words that describe what you're NOT trying to do. Here's the test: Edit your question. Don't post any requirement updates in a comment. Post a comment when you've updated the question.
    – teylyn
    Dec 22, 2022 at 22:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.