0

Created a Permission set name : John's ps

Query to be run : SELECT Id, Label FROM PermissionSet where label like 'John\'s ps'

enter image description here

Result : [object Object]: MALFORMED_QUERY: CustomPermissionSet WHERE Label LIKE 'John's ps' ^ ERROR at Row:1:Column:64 unexpected token: 's'

enter image description here

Similar Queries tried that works fine :

Query 1 : SELECT Id, label FROM PermissionSet WHERE Label = 'John\'s BBQ' , it gives proper result.

Query 2 : SELECT Id, label FROM PermissionSet WHERE Label like 'John%' , it gives proper result.

Any insights on why this is happening why LIKE when used with (') with a escape sequence is not working ?

1
  • 1
    I think this is a bug in the Developer Console. If you put your query in then toggle on "Use Tooling API", run the query, then toggle this back off again and run the query again, the error seems to disappear. It also doesn't appear to happen with the = operator, only LIKE.
    – Phil W
    Commented Nov 8 at 8:59

1 Answer 1

0

The issue you are encountering is due to the single quote in the permission set name. In SOQL, single quotes need to be escaped by using a backslash (\).

SOQL: SELECT Id, Label FROM PermissionSet WHERE Label LIKE 'John\'s ps'

Update:

I have tried with the same name in the permission set and got the same error. As per the documentation, To use the single quote(') in the SELECT query we need to use the backslash \ character to escape.

I have also tried the same name in the account object with the below query and it will work as expected. But I thing it is an issue with the PermissionSet Object.

SOQL: SELECT Id, Name FROM Account WHERE Name LIKE 'John\'s ps%'

Output: enter image description here

I suggest that create a case with Salesforce.

3
  • Hi @Tushar Jadav , the above query i tried it does not work , seems something is specific with permission set object itself , below is the result obtained when ran the query : SELECT Id, Label FROM PermissionSet WHERE Label LIKE 'John\'s ps' Result : [object Object]: MALFORMED_QUERY: CustomPermissionSet WHERE Label LIKE 'John's ps' ^ ERROR at Row:1:Column:64 unexpected token: 's' Tushar i think if you try to just create the permission set with name as 'John's ps' and perform the query using () it gives error still .
    – Abhishek B
    Commented Nov 8 at 8:10
  • @AbhishekB, I have added a comment to the answer. Commented Nov 8 at 8:52
  • 1
    Understood , Thanks @tusharJadav , i think it is an issue with permissionset in that case. Appreciate the time your gave to the issue being faced !!
    – Abhishek B
    Commented Nov 8 at 9:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .