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

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022- Season 2 has kicked off!

Users online (2,575)