cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rjack
Resolver I
Resolver I

Check for condition, yes = update, no = create

Hello, 

 

My trigger is Business central (BC) and when an record is changed, then I Get the record from BC. step 3 I get the items from a SharePoint (SP) list. then i have a condition to check if the title in SP is equal to the ID from BC. if yes, it updates the existing record. if no, a new record is created. 

 

Now, as you know that the apply to each is used because of get items. so for each condition that outputs a 'no', a new item is created because only one ID from business central is checked with each items in SP. 

 

how do i get this to work so it creates only when the item doesnt exist at all? as a work around I can have 2 flows, one to create and one to update, but really want to have just one so less number of flows are created and managed. any suggestions?

 

I tried odata filter in get items but not sure how to get it to work. kinda followed this 

 

any help will be greatly appreciated 

 

rjack_0-1624030763805.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
rjack
Resolver I
Resolver I

This is fixed by adding a filter query on 'get items' followed by a condition which compares the length of get items to '0' (zero). if '0' creates an item, if not zero, updates the item. 

rjack_1-1624389341062.png

 

condition: length(body('Get_items')?['value'])  equals 0
rjack_0-1624389315851.png

 

View solution in original post

3 REPLIES 3
zbenhallam
New Member

Hello,

Instead of using the Condition Control use the switch Control as shown bellow.

 

2021-06-18_17h59_49.png

 

 

-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a 👍

@zbenhallam Thank you for the quick response. I can see that this will work, but how do I add a dynamic content for the case condition? 

rjack
Resolver I
Resolver I

This is fixed by adding a filter query on 'get items' followed by a condition which compares the length of get items to '0' (zero). if '0' creates an item, if not zero, updates the item. 

rjack_1-1624389341062.png

 

condition: length(body('Get_items')?['value'])  equals 0
rjack_0-1624389315851.png

 

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Users online (2,139)