Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

error trying to match records

(0) ShareShare
ReportReport
Posted on by 90

I'm trying to build an automated flow to update one SharePoint list with another SharePoint list but having some trouble matching records. This should be pretty normal: get items for all the records in the master list, apply to each, get items for the list to be used to update the master. The match is on three fields: state, program, and project name.

 

The two lists are roughly the same same size, approximately 150 records. The plan is if the records match, update the master with the contents of the new list, if there is no match, create a new master from new. The columns in both files match.

 

On the 116th record I get the following error: 

 

The expression "(Program_x0020_Project_x0020_Name eq 'PIFR Runnin's River WS')" is not valid. Creating query failed.

clientRequestId: 4754eb76-70a6-455f-9571-07f8a8369130

serviceRequestId: 4754eb76-70a6-455f-9571-07f8a8369130

 

I have tried several things to fix this or narrow the problem:

 

1. Removing the ODATA filter for program name but leaving state and program, and the flow runs successfully.

2, Copied the field from it's current name to another name to remove the internal name in the message and use a column name that has not been changed. No joy on that one though I thought it might help.

3. Copied the program name from the master to the new. Though they look the same, I wanted to eliminate the possibility I wasn't seeing something. Had this work in another app where I was trying to match an email to the ms network email. No joy here either.

 

Any insight would be appreciated.

 

Carter

 

 

  • DJ_Jamba Profile Picture
    2,822 Super User 2025 Season 1 on at
    Re: error trying to match records

    You're welcome!
    d(-_-)b

  • disappointed Profile Picture
    90 on at
    Re: error trying to match records

    No, I'm not sorry I asked. There are all kinds of gotcha's in programming languages. 

    I would have never considered what you knew and especially the explanation. Too many times people offer help without an explanation and you don't learn anything from it. Thank you!!!

  • Verified answer
    DJ_Jamba Profile Picture
    2,822 Super User 2025 Season 1 on at
    Re: error trying to match records

    @disappointed 

     

    The issue is that Apply to each expression should in fact have underscores instead of spaces and it's case sensitive so something like:

     

    items('Apply_to_Each')?['Program_Project_Name']

     

     

    Or

     

    items('Apply_to_each')?['Program_Project_Name']

     

    Explanation

    This is where the fun begins 😂

    To escape a single quote, you have to escape it by replacing it with 2 single quotes. 2 single quotes means 1.
    However the expression to escape single quote is wrapped in single quotes so you have to escape it again 🤣

    Therefore, let's say one of the values behind items('Apply_to_Each')['Program_Project_Name'] is:

        O'Connell


    In the replace expression:

    replace(
        items('Apply_to_Each')['Program_Project_Name'], // the value behind that item (O'Connell)

       '''' ,// 2 singles quotes means one so find '' which means find ', then we have to wrap that in single quotes, hence

       '  ''  ' // spaced out so you can see we are wrapping 2 single quotes

       '''' // replace it with 2 single quotes and we need 4 single quotes to mean 2 single quotes

       ' '' '' ' // then we need to wrap those 4 single quotes in 2 single quotes 

    )

     

    Fun! Pretty sure you're sorry you asked! 😂

  • disappointed Profile Picture
    90 on at
    Re: error trying to match records

    Error:

     

    The expression "Program_x0020_Project_x0020_Name eq replace(items('Apply to Each')?['Program_Project_Name'],'''','''''')" is not valid. Creating query failed.

    clientRequestId: 26a27175-b472-4330-9d92-d5047a4df556

    serviceRequestId: 26a27175-b472-4330-9d92-d5047a4df556

     

    I'm trying to understand the logic. 

    Replace( String, Starting PositionNumberOfCharacters, New String )

    string = items('Apply to Each')?['Program_Project_Name']

    some of the other parts escape me

     

  • DJ_Jamba Profile Picture
    2,822 Super User 2025 Season 1 on at
    Re: error trying to match records

    @disappointed 

     

    You have one too many brackets. Try this:

    Program_x0020_Project_x0020_Name eq replace(items('Apply to Each')?['Program_Project_Name'],'''','''''')
  • disappointed Profile Picture
    90 on at
    Re: error trying to match records

    I put this in the odata filter:

     

    Program_x0020_Project_x0020_Name eq replace(items('Apply to Each')['Program_Project_Name']),'''','''''')

     

    The flow saves okay but gives the following error msg when run:

     

    The expression "Program_x0020_Project_x0020_Name eq replace(items('Apply to Each')['Program_Project_Name']),'''','''''')" is not valid. Creating query failed.

    clientRequestId: a395406a-0e6f-40f4-a89a-0acbace08cc5

    serviceRequestId: a395406a-0e6f-40f4-a89a-0acbace08cc5

     

    I've checked the column references and I think they are correct. Suggestions please.

  • DJ_Jamba Profile Picture
    2,822 Super User 2025 Season 1 on at
    Re: error trying to match records

    Hi @disappointed 

     

    That record has a single quote in the value 'PIFR Runnin's River WS' and you're not catering for potential single quotes:

     

    Try:

    Program_x0020_Project_x0020_Name eq replace(THE_VALUE,'''','''''')

     

    The replace part needs to be entered as an expression

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1