Friday, 27 August 2021

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);


}

No comments: