Skip to main content

Notifications

Community site session details

Community site session details

Session Id : IwiHxfgfUYSGz9EjZoc3kg
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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,670 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,011 Most Valuable Professional

Leaderboard
Loading started