cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
nbethea
Frequent Visitor

Contains string condition failing

Hello all. I would like to disclaim; I am limited in the information I can share due to its sensitivity.

 

Background:

The purpose of this flow is to take records from a daily generated excel report and see if those records exist in a Sharepoint list. If the record does not already exist, a new record is created. If the record does exist, the Sharepoint list record is updated using the info from the excel report. 

 

Extracting and transforming the data from both sources, adding new records to the Sharepoint list, all no issue. The problem is updating records. 

 

The process to match records between the two sources is as follows:

 

First, the records are loaded into individual select actions for final formatting. JSON Items comes from the excel sheet, Sharepoint items comes from the Sharepoint list. 

nbethea_0-1670351378982.png

 

Next, for each record in body(JSON_Items), this condition is evaluated:

 

If body(Sharepoint_Items) contains items('Apply_to_each')['ControlNo'] (the current ControlNo), update items, else create a new item.  (the update action is not there yet, the array variables are there for further steps, please ignore)

nbethea_1-1670351534018.png

Here is an example of a ControlNo/Account #: 

000141597173-1234
 
To test the update feature, this is what I do:
 
I initiate a test run for the flow; today's report is added to the Sharepoint list. Once that test is complete, I initiate another test run for the flow, using the same report. In theory, these items should all show up as 'Update' items, since they all exist in the Sharepoint list thanks to the previous run. Unfortunately, in practice, this is not the result. Instead, it sees them all as new items, but when I view the outputs for 'Sharepoint Items' and CTRL+F the current ControlNo being evaluated from 'JSON Items', it always shows up.
 
So I know for a fact that the Sharepoint list DOES contain that ControlNo, but for some reason Power Automate is unable to find the match. 
 
Any ideas where I am going wrong?
 
Hopefully I've clearly explained the issue, please let me know if I need to clarify or expand on anything.
Thank you all for your time and advice! - N. Bethea
1 ACCEPTED SOLUTION

Accepted Solutions
v-chengfen-msft
Microsoft
Microsoft

Hi @nbethea ,

The reason for this problem is:
1. body (Sharepoint_Items) is not a string type, and using Contains will always be false.


Please try:

Convert it to a string for comparison:


string(body(Sharepoint_Items))

 

Best Regards

Cheng Feng

 

View solution in original post

2 REPLIES 2
v-chengfen-msft
Microsoft
Microsoft

Hi @nbethea ,

The reason for this problem is:
1. body (Sharepoint_Items) is not a string type, and using Contains will always be false.


Please try:

Convert it to a string for comparison:


string(body(Sharepoint_Items))

 

Best Regards

Cheng Feng

 

I knew it would be something simple I was overlooking. I had no idea that the entire body needed to be converted to a string.

 

Thank you for this info, it will surely be useful for this and future projects.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (6,345)