Aug 05 2021 04:18 PM - edited Aug 05 2021 04:21 PM
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:
Feb 24 2022 05:16 AM
Jun 02 2022 05:57 PM
Nov 01 2022 01:23 PM
@IvanWilson So if I want to replace an apostrophe with a single quote would it be???
'FileLeafRef eq 'replace(variables('FileName'),''`','''')'
Nov 02 2022 02:08 AM
@Kevin2000 You can use this filter:
FileLeafRef eq 'replace(variables('FileName'),'`','''')'
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
Nov 02 2022 02:09 AM
@ganeshsanap To convert the later part to expression automatically, try:
FileLeafRef eq '@{replace(variables('FileName'),'`','''')}'
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
Nov 02 2022 07:02 AM
Dec 15 2022 11:12 AM