You need to sign in to do that
Don't have an account?
Skeeter
Note Object Trigger
I created a trigger to populate a checkbox on a custom object when a note is added. Now I need to add the criteria that the creator of the note is the same as a user lookup on the custom object. I'm not sure how to get the lookup and add to the criteria.
I need the trigger to fire only when the note creator = id from the client__c lookup field on the ticket__c object.
Any help is greatly appreciated.
I need the trigger to fire only when the note creator = id from the client__c lookup field on the ticket__c object.
Any help is greatly appreciated.
trigger NoteAI on Note (after insert) { //Collect all ParentIds into a set Set<Id>incIds = new Set<Id>(); //List of all Incidents to be updated with the flag List<EscalatedTicket__c> toUpdate = new List<EscalatedTicket__c>(); //Collect all ParentIds for(Note n : trigger.New){ if(n.ParentId.getSobjectType() == EscalatedTicket__c.SobjectType){ incIds.add(n.ParentId); } } //Collect all records with the above list of parentIds and return only those records List<EscalatedTicket__c> TicList = [select Id, ClientUpdated__c from EscalatedTicket__c where id in:incIds]; if(toUpdate !=null){ for(EscalatedTicket__c inc:TicList){ inc.ClientUpdated__c = true; toUpdate.add(inc); } if(toUpdate.size()>0){ Database.update(toUpdate,false); } } }
Let me know if you have any issues in it or you need more help on this.
Thanks,
Abhishek
All Answers
You can not prevent the trigger fire but you can put a check after getting the client__c from ticket__c object and then comparing the ownerid and client__c field
Hope this Helps ,
Thanks ,
Vishal
Let me know if you have any issues in it or you need more help on this.
Thanks,
Abhishek