You need to sign in to do that
Don't have an account?
Claire Sunderland 1
Exclude converted leads from trigger
I am a Salesforce admin working to finish a Trigger in our Sandbox for tesitng. I have an Apex Trigger that is being used to rollup certain activities onto the lead record. When I try to convert the lead I'm hitting an error that I'm interpreting is because it's pushing an update to the activities on the record and then looking for the Lead.Id but this no longer exists. Can someone show me how to trigger only if the Lead is not converted?
Error message:
Error: There was an error converting the lead. Please resolve the following error and try again: ActivityRollups: execution of AfterUpdate caused by: System.SObjectException: Invalid Id for Lead
Error message:
Error: There was an error converting the lead. Please resolve the following error and try again: ActivityRollups: execution of AfterUpdate caused by: System.SObjectException: Invalid Id for Lead
Since we are working from the Task, to minimise doing a query to get the associated contacts/leads, just test the WhoId as it is contained on the task.
Since contacts records start with a prefix of '003', let us test the what the Id starts with and then use the same remove function for those records before we pass the list to the Rollup helper class
Note that leads are prefixed by 00Q
Hope this helps
Andrew
All Answers
Hope that your day is off to an amazing start. I would use an IF statement to look for the IsConverted field equals false before calling a class's method in your trigger. Example is below and hope this helps. May God bless you abundantly.
If(Lead.IsConverted == false){
do xyz
}
Best Regards,
Anthony McDougald
Since we are working from the Task, to minimise doing a query to get the associated contacts/leads, just test the WhoId as it is contained on the task.
Since contacts records start with a prefix of '003', let us test the what the Id starts with and then use the same remove function for those records before we pass the list to the Rollup helper class
Note that leads are prefixed by 00Q
Hope this helps
Andrew