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

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
Super User
Super User

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 🙂

ekarim2020
Super User
Super User

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

Helpful resources

Announcements
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.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

Users online (1,060)