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
Srini KonduruSrini Konduru 

Anchor tag not working in salesforce1 mobile app


Hi,

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 using href tag. Please find below the code.

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

                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.
Gaurav KheterpalGaurav Kheterpal
Instead of anchor tag, you should use navigateToList

See this example for reference
 
<apex:page >
  <a href="javascript:sforce.one.navigateToList('00Bi0000006Ezi7', 'All Accounts', '001');">
    All Accounts
  </a>
</apex:page>
You can lookup the official documentation here (http://www.salesforce.com/us/developer/docs/salesforce1/Content/vf_dev_best_practices_navigation.htm).

If my answer helps resolve your query, please select it as a 'Best Answer' so that it benefits others and helps us improve the overall quality of the forums.