function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SabrentSabrent 

No viable alternative at character '%'

No matter where I put the excape character, i keep getting the error - No viable alternative at character '%'

 

soql +=' and Account__r.Name LIKE \' ''%\'+String.escapeSingleQuotes(accountName)+'%\'';

 Can someone please point out where am i missing a qoute?

 

Thank you.

Best Answer chosen by Admin (Salesforce Developers) 
Avidev9Avidev9

You seem to have extra quotes

 

soql +=' and Account__r.Name LIKE \'%'+String.escapeSingleQuotes(accountName)+'%\'';

All Answers

Avidev9Avidev9

You seem to have extra quotes

 

soql +=' and Account__r.Name LIKE \'%'+String.escapeSingleQuotes(accountName)+'%\'';
This was selected as the best answer
Marko LamotMarko Lamot
soql +=' and Account__r.Name LIKE \'%'+String.escapeSingleQuotes(accountName)+'%\'';
Dev@Force.ax647Dev@Force.ax647

String accountName='abc';
List<Account> a=Database.query('Select id,Name From account where name like \'%'+String.escapeSingleQuotes(accountName)+'%\'');

SabrentSabrent
Thanks everyone. All solutions resolved the error. I marked the first answer as solution.