web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Contains string condit...
Power Automate
Unanswered

Contains string condition failing

(0) ShareShare
ReportReport
Posted on by 12

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
Categories:
I have the same question (0)
  • Verified answer
    v-chengfen-msft Profile Picture
    on at

    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

     

  • nbethea Profile Picture
    12 on at

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard