You need to sign in to do that
Don't have an account?
Sangeet kasera
How to do Dynamic SOQL Query using NOT IN operator for Single String
I have one Dyanmic query using Not In operator but it is giving an error when i am trying to run my code i used several ways but still not found the solution.
I am not good in using escape character in where condition of SOQL
Please help me out
Query -
String CreatedById = '5006F00002iorNcQAI';
I Tried
Regards,
Sangeet
I am not good in using escape character in where condition of SOQL
Please help me out
Query -
String CreatedById = '5006F00002iorNcQAI';
I Tried
- customObjQuery = customObjQuery+' And (Createdby.Id NOT IN:CreatedById)';
- customObjQuery = customObjQuery+' And Createdby.Id =\''+IN:CreatedById+'\'';
Regards,
Sangeet
CreatedById = '5006F00002iorNcQAI';
customObjQuery = customObjQuery+ ' And Createdby.Id != '+ CreatedById;
Also can you once can you add below statement as well:
System.debug(customObjQuery);
Looking forward for your response.
All Answers
As I see there is a documentation regarding this in the link : https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_quotedstringescapes.htm#:~:text=SOQL%20defines%20several%20escape%20sequences,is%20the%20backslash%20(%5C)%20character.
Does this helps??
Regards,
Anutej
Try the below:
String CreatedById = '5006F00002iorNcQAI';
customObjQuery = customObjQuery+ ' And Createdby.Id != \''+ CreatedById +'\'';
Thanks,
Maharajan.C
when i am using querywhatever you have given then code is running fine but AND operator is not accepting in debug
Like I Used - commentQuery = commentQuery+' And Createdby.Id =\''+CreatedById+'\'';
In Debug I Found-
And @AnuTej, I have already checked it but it didn't give the clear understanding of using escape character.
@Mahajan, If you have better knowlegde regarding Escape character please take a time and help me out by some example or with any doc.
Regards,
Sangeet
CreatedById = '5006F00002iorNcQAI';
customObjQuery = customObjQuery+ ' And Createdby.Id != '+ CreatedById;
Also can you once can you add below statement as well:
System.debug(customObjQuery);
Looking forward for your response.