Skip to main content

Posts

Showing posts with the label How to add error message in a Salesforce Apex Trigger

How to make hyperlink in trigger.addError message ?

 Use Case - On Lead conversion, we would want to mandate user to use existing account instead of creating new account .  For that we have written logic Account before trigger, if there is an existing records then show error message along with Record Link.  for(Account account : accounts){      String link = '<a href="https://yourdomain.lightning.force.com/'+   account.Id +'" target="_blank">'+ account.Name + '</a>';          account.addError('Please choose Existing Account Record because there is an already existing   Resident Record having same SSN '+link); }