You need to sign in to do that
Don't have an account?
capture errors and showing a different one
Hi!
Im new in capturing errors and showing errors within salesforce and....I am a bit lost....
I have a trigger that is fired when converting a lead into account. This trigger will update one field of the account.
The problem is that in our organization we only let the sales managers convert into exisiting accounts, not into new ones. But some of them still try to convert into new ones and then, because of the trigger they get this error:
Save error: Method does not exist or incorrect signature: addError(String)
trigger UpdateNumbercontactsWhenConverting onLead (afterupdate) {
Set<Id> addAccounts = newSet<Id>();
for (Lead lead: Trigger.new){
if(lead.IsConverted){
addAccounts.add(lead.ConvertedAccountId);
}
}
if
(addAccounts.size()>0){Map<Id,
Account> Updatevalue = new Map<Id,Account>([select Number_contacts__c fromAccountwhereId in: addAccounts]);for (Accountacc:Updatevalue.values()){
if (acc.Number_contacts__c==NULL) {
addError(
'You cannot convert a lead into a new account only into an existing one');}
acc.Number_contacts__c=acc.Number_contacts__c+1;
}
updateUpdatevalue.values();}
}
Thanks!!
Let me know if it works for you. Just change this :
To this :
Thanks
Ankit Arora
Blog | Facebook | Blog Page
Hi,
Unfortunately this doesnt work for me.
In the moment that the trigger is being fired I am in the conversion screen. Thats the main problem, I dont know how to show the error.
Thanks Ankit!