You need to sign in to do that
Don't have an account?

What's wrong with this simple SOQL ? - How to get event/task related to Lead object ?
Good day,
Any expert please point out what's wrong with my query below and get error "invalid query filter operator"
SELECT Id FROM Event WHERE WhoId like 'ABC%'
Thanks
I am just trying to give you an structure of your trigger , you can try it
I have written this trigger for only single event insert, you should write it for bulk data also using collections set,map, list if you need to. Please ask me if you have any problem.
All Answers
Let me explain you how do a SOQL works in Apex Compiler
Lets take your example
SELECT Id FROM Event WHERE WhoId like '00Q%'
When you write this and compile , first Compiler checks sytax from left to right
1) Syntax of Query SELECT Id FROM Event that is correct in your case till
2)systax of where is also correct till : WHERE WhoId
3) in where condition then compiler checks whther the operator on the field condition is allowed or not, in your case you are using like with field id and that is not allowed thats why you see this compiler error "invalid operator on id field"
even if you remove like and use = operator then you will see "invalid ID field: 00Q%" because compiler will find incompatible value to compare for id value
I hope it is clear to you.
Thanks Shashikant Sharma !
I also doubt on why "whoId" can't be query here ? how can i refer whether the event is coming from Lead object or not , what is the best way to check that ?
You can use this query
Thanks Shashikant Sharma and here my challenge :-
Assumption :- this is after insert trigger from Event object
1. After event records inserted, i need to find out the Lead object id that linking it
2. After get the lead object id, i need to know how many records in Event object currently link to that Lead object
3. Find out the total of event records that linked to related Lead object
4. update to Lead object's field with the total number
Any chance to use single query to accomplish the above ?
I am just trying to give you an structure of your trigger , you can try it
I have written this trigger for only single event insert, you should write it for bulk data also using collections set,map, list if you need to. Please ask me if you have any problem.
Awesome Shashikant Sharma !
Thanks a lot for your warm input !