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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (4,463)