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
Manuel EcheverriaManuel Echeverria 

sforce.one.navigateToRelatedList Is not working

I am new in salesforce and I'm trying to make a call from a visualforce page inside salesforce1 (now called lightning, I think) to a Related List of contacts. My page show some options related to the Account object and one of this options is to show its Contacts (that's what I want but this code is not working):
 
<apex:outputPanel > 
<a href="sforce.one.navigateToRelatedList('Contacts', '{!idAccount}');"> 
 <input type="button" value="Contacts" class="register-button"/> 
</a> 
</apex:outputPanel>

I just want to show this: Is the same that you can see in Salesforce Lightning under Accounts/Related/Contacts
User-added image

And then...
User-added image
Best Answer chosen by Manuel Echeverria
bob_buzzardbob_buzzard
This code:
 
<a href="sforce.one.navigateToRelatedList('Contacts', '{!idAccount}');">

tells the browser to create a link to the page 'sforce.one...' etc.  This is a JavaScript function, so you need to tell the anchor tag to treat the HREF as JavaScript rather than a URL. E.g.
 
<a href="javascript:sforce.one...">


 

All Answers

bob_buzzardbob_buzzard
This code:
 
<a href="sforce.one.navigateToRelatedList('Contacts', '{!idAccount}');">

tells the browser to create a link to the page 'sforce.one...' etc.  This is a JavaScript function, so you need to tell the anchor tag to treat the HREF as JavaScript rather than a URL. E.g.
 
<a href="javascript:sforce.one...">


 
This was selected as the best answer
Manuel EcheverriaManuel Echeverria
Oh Thanks a lot. I didn't know that. Now it works perfectly.