You need to sign in to do that
Don't have an account?
Michael Allen
Doing a 'nested' AND query in SOQL
Hi,
I have filtered 'Related Lists' (actually Apex Tables) on Account. I need to do a 'nested' AND statement.
Query is as follows:
The problem is it excludes all Tasks owned by the User AND all Tasks where Subject starts with 'Email: '.
I want to do something akin to this:
Any help would be greatly appreciated.
Thanks
I have filtered 'Related Lists' (actually Apex Tables) on Account. I need to do a 'nested' AND statement.
Query is as follows:
SELECT Id, Subject, LastModifiedDate FROM Task WHERE isClosed = FALSE and (NOT Subject LIKE'%Email: %') and OwnerId != '00520000002DBP2' ORDER BY ActivityDate DESC NULLS LAST LIMIT100];I want to show all open Tasks, except Tasks owned by the specified user that have a Subject starting with 'Email: '
The problem is it excludes all Tasks owned by the User AND all Tasks where Subject starts with 'Email: '.
I want to do something akin to this:
SELECT Id, Subject, LastModifiedDate FROM Task WHERE isClosed = FALSE and ( (NOT Subject LIKE '%Email: %') and OwnerId != '00520000002DBP2' ) ORDER BY ActivityDate DESC NULLS LAST LIMIT 100];...but can't find out any information on how to do it syntactically. Do I need to nest a whole other query in it?
Any help would be greatly appreciated.
Thanks
Please try this and let me know if it works
thanks
Shyama
Thanks for this. I like your thinking - I didn't think of it that way. But sadly it's throwing back:
Error: Compile Error: expecting right square bracket, found '(' at line 47 column 500
This is the first bracket. Shown in bold.
....WHERE isClosed=FALSE AND (Not (Subject....
I mentioned earlier that this query builds a 'filtered related list'. The full query is as follows. I had deliberately kept it slim last time for ease. I'm drawing a blank on this one I'm afraid. I'm really not sure how to proceed...
Thanks
I tried to use the query in an apex class (removing the custom task fields from your query) and it looks something like this with no compile errors:
This is the code:
Hope this helps. Good luck.
Thanks.