cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Santhosh_V_26
Helper I
Helper I

Need help to compare the list items and then do an action based on the output.

Hi All,

 

Flow Details: I am having a flow that gets the data from email and create a item in SPO List. And the column names are Record Number, City, Country and so on. I was getting multiple emails for one record number and at that time the flow need to check If the record number is existing or not in the SPO list.

Actions:

  • If the record number is already exists in the list, then need to just update the Column values
  • If the record number is not found, then need to create an item in the list.

Any suggestions on the condition part..

Thank you.

             

2 ACCEPTED SOLUTIONS

Accepted Solutions
henkenTech
Resolver II
Resolver II

  • When you get your items, add an OData filter for the Record id (ColumnName eq 'RecordId').
  • Then, in your condition, count the returned items using the length() function and use the greater than condition with a 0 on the other side. When the item is not yet in the list, the No branch of the condition will be activated and the other if the item is already in the list.
  • Then, use a Create Item and Update Item respecitvely.

Hope this help 🙂

View solution in original post

ekarim2020
Community Champion
Community Champion

For the record number, you should check that the SP list ensures that there are no duplicate Record numbers:

ekarim2020_5-1625414759242.png

It probably needs to be a required field too:

ekarim2020_7-1625414968866.png

Filter query can be used to Get Items (uses oData filters to construct the query):

ekarim2020_2-1625414153320.png

 

Use a condition to check to see if any records are returned:

If length(outputs('Get_items')?['body/value']) is greater 0 - that means a record was returned by the filter:

ekarim2020_12-1625416775395.png

 

Note that even though only one record is returned, Get Items returns an array, which Power Automate will need to cycle through, hence the use of Apply to each loop.
 
I hope this helps.

 

Ellis

View solution in original post

2 REPLIES 2
henkenTech
Resolver II
Resolver II

  • When you get your items, add an OData filter for the Record id (ColumnName eq 'RecordId').
  • Then, in your condition, count the returned items using the length() function and use the greater than condition with a 0 on the other side. When the item is not yet in the list, the No branch of the condition will be activated and the other if the item is already in the list.
  • Then, use a Create Item and Update Item respecitvely.

Hope this help 🙂

View solution in original post

ekarim2020
Community Champion
Community Champion

For the record number, you should check that the SP list ensures that there are no duplicate Record numbers:

ekarim2020_5-1625414759242.png

It probably needs to be a required field too:

ekarim2020_7-1625414968866.png

Filter query can be used to Get Items (uses oData filters to construct the query):

ekarim2020_2-1625414153320.png

 

Use a condition to check to see if any records are returned:

If length(outputs('Get_items')?['body/value']) is greater 0 - that means a record was returned by the filter:

ekarim2020_12-1625416775395.png

 

Note that even though only one record is returned, Get Items returns an array, which Power Automate will need to cycle through, hence the use of Apply to each loop.
 
I hope this helps.

 

Ellis

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!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Kudoed Authors
Users online (1,651)