- Suppose you have a Lead with one or more activities.
- Suppose when you convert the Lead, on the OOTB Lead Convert page, you add a new activity.
What happens at Lead Conversion and in what order
- Before/after update trigger fires on the Tasks that existed on the Lead pre-conversion.
- Before/after insert trigger fires on the new Task specified in the Lead Convert UI
In both use cases, the Task is prepopulated with a
WhatId of the parent Opportunity
And, for Task Validation Rules…
- If the Task Validation Rule fails the Tasks existing pre-conversion, the Lead Conversion UI will surface the error
- If the Task Validation Rule fails the Task specified on the conversion page, the Task is not inserted nor is an error surfaced
If you want your trigger to detect the Task as participating as part of the Lead Conversion there is no robust solution.
If all Lead Converts go through the OOTB Lead Convert page, then
System.URL.getCurrentRequestUrl().getPath().endsWith('leadconvert.jsp') will work