Add Navigation Controls Using sforce.one

Connect your page to the Salesforce1 navigation system by using sforce.one navigation functions.

Visualforce pages running in Salesforce1 often have to interact with or link to other pages in the application. Common navigation functions are available through the sforce.one object, a JavaScript utility library automatically made available when running inSalesforce1.

  1. Open the Developer Console and click File | Open, then open your page.
  2. At the bottom of the script block, before the closing </script> tag, add the following code to your page.
    ul.addEventListener("click", function(e) {
    sforce.one.navigateToSObject(e.target.getAttribute("data-id"));
    });
  3. Reload the app and view your changes.

Your mini app doesn’t look different at first. But try tapping an account. You’ll navigate to the account’s detail page, where you can view the account, the account feed, and so on. What’s more, by using sforce.one to navigate forward, you can also use the Salesforce1 back arrow to navigate back to where you started—your Latest Accounts page. Cool!

The navigation functions provided by sforce.one let you tie your custom app functionality into the overallSalesforce1 navigation system. This lets your pages behave just like built-in functionality when it comes to navigation. You can use different sforce.one functions to navigate to individual records, to specific feeds or feed items, to lists and related lists, and even to general URLs. See this unit’s resources for more details on this useful library.