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
NatashaNatasha 

How to handle Single Quote in the Value to be searched?

Hi,
I need records as a result of query such as:
Select Id, Description from Task where Subject ='Profile Email : Season's Greetings'
But this gives me a MALFORMED QUERY Exception. Using "includes" also does not work in this case. Query such as
Select Id, Description from Task where Subject includes ('Profile Email : Season's Greetings')
also runs into exception due to the single quotes present afte the word Season. Double Quotes are not allowed in SOQL.
Please suggest me the best way in which such queries can be invoked?

Natasha

SuperfellSuperfell
Off the top of my head, i think you just need to escape the ', so try
Select Id, Description from Task where Subject ='Profile Email : Season\'s Greetings'
NatashaNatasha

thanks it worked!
I have included in my code to replace all occurrences of single quotes with \' .
With this the query runs fine.
thank you so much!
Natasha