You need to sign in to do that
Don't have an account?
raghavi SR
Throw error on changes during lead conversion
Hi i have a trigger to fire warning message when the first name and last name are interchnaged during conversion.
trigger LeadWarning on Lead (after update)
{
for (Lead l:trigger.new)
{
if (l.IsConverted && trigger.oldMap.get(l.Id).First_Name_Kana__c==trigger.newMap.get(l.Id).Last_name_Kana__c && trigger.oldMap.get(l.Id).Last_name_Kana__c==trigger.newMap.get(l.Id).First_Name_Kana__c)
{
Trigger.new[0].addError('#####');
}
}
}
It should throw error only when the changed are made during conversion. but it is throwing error if the name is edited even before conversion. what is the missing part?
trigger LeadWarning on Lead (after update)
{
for (Lead l:trigger.new)
{
if (l.IsConverted && trigger.oldMap.get(l.Id).First_Name_Kana__c==trigger.newMap.get(l.Id).Last_name_Kana__c && trigger.oldMap.get(l.Id).Last_name_Kana__c==trigger.newMap.get(l.Id).First_Name_Kana__c)
{
Trigger.new[0].addError('#####');
}
}
}
It should throw error only when the changed are made during conversion. but it is throwing error if the name is edited even before conversion. what is the missing part?
write your tigger on before update not on after update
Thanks let us know if it helps you
Thanks for the responses.
Even after i changed to before update, i get the error when the name is edited before conversion itself. Is there any other possible changes?
Below code can fullfill your requirements. Hope this will work for you.
Please mark this as best answer if this solves your problem.
Thank you,
Ajay Dubedi