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
satihillyersatihillyer 

sforce.one.navigatetolist not working

Any idea why this is not rendering the page on Salesforce1?

<apex:page >
  <script>
      if ( (typeof sforce != 'undefined') && (sforce != null) ) {
          sforce.one.navigateToList('00BG0000008Wtyc', 'AllOpenLeads', 'Lead');
      }
  </script>
</apex:page>

I just want to redirect to the all open leads list view.
dev_sfdc1dev_sfdc1
Hi,
 Please call the condition inside the function in javascript..


<script>
          $(document).ready(function(){
                            if((typeof sforce.one!='undefined') && (sforce.one !  = null)) {
                                            sforce.one.navigateToList(listviewId, listviewName,scope);   ---------------> Pass your values here
                              }         

          });

</script>

If it resolves your issue,Please mark it as a solution..
Nitin SehgalNitin Sehgal
Hi satihillyer,

You can simply use this:
<apex:page >
  <script>
      window.onload=function(){
            if(sforce.one){
                 sforce.one.navigateToList('00BG0000008Wtyc', 'AllOpenLeads', 'Lead');
            }
       };
  </script>
</apex:page>

satihillyersatihillyer
That didn't work, still getting a blank page when I try it.
satihillyersatihillyer
@nitin - that didn't work either, still shows a blank page when I try it.
Nitin SehgalNitin Sehgal
Please check the LisatViewid and ListViewName again and also check if there is any JavaScript error because this was working fine when i used this.
satihillyersatihillyer
I see this error in the javascript console, definitely have the right listview name and id.
Uncaught ReferenceError: sforce is not defined
Nitin SehgalNitin Sehgal
I don't think that you should get this error because salesforce automatically adds the sforce library to the Vf page if you are working with salesforce1 app. well you can also use this on the top of the page and then check if the error still exists.

<script type='text/javascript' src='/soap/ajax/29.0/connection.js'></script>
<script type='text/javascript' src='/soap/ajax/29.0/apex.js'></script>
satihillyersatihillyer
I don't get it, still doesn't work.

It's a VF tab. Salesforce1 is enabled, the "Available for Salesforce mobile apps" checkbox in the VF page is checked. Lead ListView ID is 00BG0000008Wtyc and Lead ListView Name is AllOpenLeads

All I want is when you click this tab in the Salesforce1 mobile app, it redirects you to the lead list view.
Pat PattersonPat Patterson
I think the detail you are missing is that the 'scope' parameter should be the three character object ID, for Lead, this is '00Q', so your code should look like

    sforce.one.navigateToList('00BG0000008Wtyc', 'All Open Leads', '00Q');