How to handle single quotes in the filter property with Get Items actions


If  you are using the SharePoint Get Items actions and using the Odata Filter Query syntax, then you need to handle single quotes in your filter syntax.


Since a single quote is a special character, you need to use another special character to "escape" it. This lets the system know that the next character should be treated as a regular character rather than what it usually means.


In other languages, the escape character could be a backslash, however in Power Automate, the escape character is a single quote. So, to escape a single quote, you need to type two single quotes. We can use the replace function to perform this opearation


Let's have a look at a standard replace function first:


This will look for any occurrence of 'this' in my Filename variable and replace with 'that'. 


Now, here's what it looks like when we want to replace single quotes with two single quotes:



Here is the text version. note that there are no double quotes here, only multiple single quotes:

FileLeafRef eq 'replace(variables('FileName'),'''','''''')'


Here is an explanation of the colour coding:

  1. Everything between the 'green quotes' is a Power Automate expression, not plain text
  2. The 'yellow quotes' are normal quotes for wrapping strings, e.g. replace(myVariable,'this', 'that')
  3. The 'light blue quotes' are there to escape the following character (a single quote)
  4. The pink quote (') is the character to find
  5. The two orange quotes (') are the characters to replace the found text with
2 Replies