Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Contains string condition failing

Like (0) ShareShare
ReportReport
Posted on 6 Dec 2022 18:50:28 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
  • nbethea Profile Picture
    12 on 07 Dec 2022 at 17:10:15
    Re: Contains string condition failing

    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.

  • Verified answer
    v-chengfen-msft Profile Picture
    on 07 Dec 2022 at 03:07:29
    Re: Contains string condition failing

    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

     

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Automate - Building Flows

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 148 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 144 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 131

Overall leaderboard
Loading started