function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SF DEVSF DEV 

addError in Trigger with hyperlink

Unable to get hyperlink in add.error code, In trigger.

 

I have seen codes in forum, but wrkg out, as its giving like output text, i need in clickable format.

 

i tried this:

o.addError('ERROR TRM100: There is already an identical record: <a href=\'https://cs2.salesforce.com/' + Acctid.id + '\'>Record Number ' + Acctid.id + '</a>');

 

Best Answer chosen by Admin (Salesforce Developers) 
Rahul SharmaRahul Sharma
It is not working in version 27 of Trigger for some reason.
Try downgrading to 26 or some lower version.

All Answers

Rahul SharmaRahul Sharma
It is not working in version 27 of Trigger for some reason.
Try downgrading to 26 or some lower version.
This was selected as the best answer
SF DEVSF DEV

Thanks Rahul, yes i changed to 26 version...

Rahul SharmaRahul Sharma

I was wondering if we could log this issue to salesforce known issues.

 

SF DEVSF DEV

Yes, we have too..

Wiz76Wiz76

I've been trying to figure this out for a couple hours now (still new to APEX development).

 

Thankfully after plundering through post after post I found this. Changing the API version fixed the problem and now my contact shows up as a hyperlink, whereas before the html markup showed up as text.

 

Thanks so much!

Srini KonduruSrini Konduru
Hi,

I tried this and it is working in browser but it is not working in Salesforce1 app. I developed a trigger on Opportunity and if the validation in trigger pass then I am displaying an error message on the top and provide a link to that error message.

String sBreak = '</br>';
               String first = '<a href="';
               String fullFileURL = URL.getSalesforceBaseUrl().toExternalForm();
               Schema.DescribeSObjectResult r = Contact.sObjectType.getDescribe();
               String keyPrefix = r.getKeyPrefix();
               String Relatedlist = '?rlid=RelatedContactList&id=';
               String link = '" onclick="_gaq.push">';
               String Errormessage = System.Label.Key_Contact_Error_Message;
               Link = Link + System.Label.Key_Contact_Link;
               Link = Link + '</a>';

// The below statement add error in the screen
                Opptys[0].addError(Errormessage + sBreak + first + fullFileURL + '/' + keyPrefix + Relatedlist + AccountIds[0] + Link, false);

This is perfectly working in normal browsers but not working in Salesforce1 app. Can any one please help me in this.
nive jnive j
Hello,

We are facing the same issue in Salesforce1 app.  Did you find a solution?
Srini KonduruSrini Konduru
Hi nive J,

Not yet. I have contacted Salesforce R&D, they told me that it is a limitation in Salesforce. This cannot be done in mobile version with this approach.
khillan bhardwajkhillan bhardwaj
Hi,
To show html link or any thing else you need to write addError as below :

a.addError('This ID is already being used in Account:<a href="any link" >test name</a>',FALSE);

Hope this help you.

Thanks
khillan