cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper IV
Helper IV

Re: Create new item if it doesn`t exist

Hi @MattWeston365  the lenght expression uses the Get items that gets items from list B whereas the Open Points W is a column of list A. I hope this helps.

Highlighted
Helper IV
Helper IV

Re: Create new item if it doesn`t exist

I'm certainly willing to discuss it and share my screen with you. How/when could we arrange that?

Highlighted
Helper IV
Helper IV

Re: Create new item if it doesn`t exist

@MattWeston365  would you have time today?

Highlighted
Helper IV
Helper IV

Re: Create new item if it doesn`t exist

@abmI think you were pretty close to the solution when you said to enter my first two conditions into the ODATA query but I get an error because it is not a column of list B (=my Get item list). In fact, I want a condition on my trigger step list (that is, When an existing item is modified). I wish we could put conditions on the trigger step but I understand this is not an available feature yet.

I also tried to enter the condition in Apply to Each: the flow succeeds but the condition is always false (although I know it should be true).

Can you help me further?

Someone marked my post as Solved and therefore it doesn't have much visibility anymore, I believe.

 

101.JPG102.JPG

Highlighted
Super User III
Super User III

Re: Create new item if it doesn`t exist

Hi @Dricc 

 

Lets go back to your requirement. There are so many updates after that.

 

Your requirement is:
When I modify the column 'Open Points W' of list A by switching to Yes,
I want the flow to create a new item in the 'S...o ref' column of list B if it doesn't yet exit in list B.
This newly created entry should be the 'U...Nr' of the item that I modified.

 

Couple of questions:
(1) In list B what value you compare. Please mention List A column and List B Column.
(2) Also if it doesn't exist that means are we creating a new item or we updating a column in List B using List A value?
(3) You mentioned "This newly created entry should be the 'U...Nr' of the item that I modified". Is this U..Nr is a column in List A?

 

If you could answer the above that will be helpful.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Highlighted
Helper IV
Helper IV

Re: Create new item if it doesn`t exist

Thank you @abm 

(1) list A column is 'Open points W' list B column is 'S...o ref'

(2) if it doesn't exist in list B we are creating a new item in list B.

(3) this new item in list B will have the 'S...o ref' filled in with the 'U...Nr' column of list A

Highlighted
Super User III
Super User III

Re: Create new item if it doesn`t exist

Hi @Dricc ,

 

Thanks for your reply. Will get back to you.

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Highlighted
Helper IV
Helper IV

Re: Create new item if it doesn`t exist

I tried a bit everything. both eq and ne separators for my ODATA query. both length "is egual to" 0 and "is not equal to 0" in my condition. Depending on how I set up my flow I either get multiple items created (20 items for example) or never any. What I want is 1 single item to be created when condition is met.

Highlighted
Super User
Super User

Re: Create new item if it doesn`t exist

Hi @Dricc I have sent you a DM to try to set up a Teams call so that we can get this nailed. If you can please respond and I can put some time aside tomorrow 





Did my reply help? Please give it a thumbs up.
Did I answer your question? Please mark my post as a solution!
If you liked my response, please consider giving it a thumbs up. THANKS!


Proud to be a Flownaut!





Community Leader: Black Country PowerApps & Flow User Group

Highlighted
Super User III
Super User III

Re: Create new item if it doesn`t exist

Hi @Dricc ,

 

Please see below steps which I created and it is working as expected.

 

First I created two lists. ListA and ListB

 

ListA, I have created one column called 'Open points W' which is a check box (Yes/No) and another text column called UNR.

 

l1.png

 

 

List B, I have created a text column called SRef. SRef value is updated from ListA column UNR when the new item gets created in ListB.

 

l2.png

 

Next step is to build the flow steps:

 

Here our trigger is when ListA item is created or modified.

l3.png

 

Next step is check Open points W is set to 'Yes'

 

l4.png

 

Next we will have flow step Yes and No conditional branches. If it's no we don't have to do anything. So we are not going to add any steps under the No branch. All of the below steps are added under the 'Yes' branch. There are couple of steps here. Here is the preview of the steps. Below I will show the detailed steps.

l5.png

 

So under the above Yes condition the first step is Get Items. Here we need to find whether List B SRef exists by checking SRef equal to UNR. Here I am setting the filter query and top count to 1. Just incase if there are more than one record we don't need to return everything. All we want is whether a record exists or not.

l6.png

Next step is the Compose statement. So here we need to find the record count. As you can see below it's an expression. Copy and past the below expression including double qutoes under the input box.

"length(body('Get_items')?['value'])"

l7.png

Next we need to add another condition to check the record count.

l8.png

Naturally we get another Yes/No flow branch. So for count > 0 we don't have to do anything.  See below.

l9.png

 

Under the No condition we need our final flow step which is create item. Here I am mapping the title and SRef values from ListA. Feel free to change the mapping accordingly.

 

l10.png

 

Let me know how it goes.

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog

View solution in original post

Highlighted
Helper IV
Helper IV

Re: Create new item if it doesn`t exist

Thanks @abm 

I get this at the end of my flow. Did I set up something wrong?

104.JPG

Highlighted
Super User III
Super User III

Re: Create new item if it doesn`t exist

Hi @Dricc ,

 

You need to remove the Apply to each loop. There are no records under the No condition so the "Create item" won't be executed. 

 

Try to delete that loop and add the create item. See whether that works or not.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Highlighted
Helper IV
Helper IV

Re: Create new item if it doesn`t exist

It looks promissing. I will test it later today.

Highlighted
Helper IV
Helper IV

Re: Create new item if it doesn`t exist

@abmit works perfectly. Thank you very much!

Highlighted
Super User III
Super User III

Re: Create new item if it doesn`t exist

Fantastic. Thanks for letting me know.


Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog

Helpful resources

Announcements
firstImage

Super User Program Update

Three Super User rank tiers have been launched!

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Top Solution Authors
Top Kudoed Authors
Users online (7,698)