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
Swapna MistrySwapna Mistry 

Error: Compile Error: Found punctuation symbol or operator '%' that isn't valid in Apex

I am not a developer. I am just trying to update a test class based on instructions provided to me by a previous contractor. I added the necessary info, but I am getting a compile error on a line that I did not touch and did not have any issues with when I updated this test class about a month ago. 
 
User u = [SELECT Id FROM User WHERE UserRole.Name LIKE '%TSM%' LIMIT 1];

Please help. What is the correct syntax supposed to be? 

User-added image
Best Answer chosen by Swapna Mistry
Swapna MistrySwapna Mistry
Thank you so much for getting back to me. I found the issue was that I was missing a closing ' on the line of code I added. Once I fixed that, I was able to save the Apex.

All Answers

Devi ChandrikaDevi Chandrika (Salesforce Developers) 
Hi swapna,
I tried executing same line of code in my org.I am able to execute without any errors.There is nothing to correct in  syntax.Try by removing all the code from controller and paste same code.

Hope this helps you
If this helps kindly mark it as solved so that it may help others in future.

Thanks and Regards
Swapna MistrySwapna Mistry
Thank you so much for getting back to me. I found the issue was that I was missing a closing ' on the line of code I added. Once I fixed that, I was able to save the Apex.
This was selected as the best answer