[SalesForce] Salesforce1 navigation – how to go to a Visualforce page

I've done a bit of tinkering with the Salesforce1 warehouse example (tutorial 6 here). I've successfully adapted the code to work with my own custom object, and I've got records showing up as pins on a Google map. Now I'm trying to change the links that show when you click the pushpins so that you go to a Visualforce page instead of the original Salesforce object (or default SF1 version of it in this case).

Here's the code I've tried most recently. Nothing happens when you click on the link in the pushpin. I've got this working on the non-salesforce1 side of things, but the methods of navigation are different.

if(sforce.one){
    var apexstr =  '/apex/SimpleSiteProgram?id='; 
    warehouseNavUrl =                       
    'javascript:sforce.one.navigateToUrl(\''+ apexstr + warehouse.Id + '\')';

Below is the text that appears in the browser lower margin when you hover over the pushpin link in Salesforce1 mode. Any ideas on what is wrong here? Do I need to spell out the whole Url?

attempted link to VF page in Salesforce1

edited to add

When I click on the pushpin the Salesforce1, I get the following error message in the javascript console.

"Uncaught TypeError: undefined is not a function"

which would appear to indicate the code shown wasn't being understood as a javascript function, but the following code works in Salesforce1:

warehouseNavUrl =                       
  javascript:sforce.one.navigateToSObject(\'' + warehouse.Id + '\')';

I'm not too experienced in javascript. Any thoughts about where I've gone wrong?

Best Answer

You shouldn't have to spell out the whole url.

Assuming that you are getting no errors when you go to this page using your browser, you need to enable the page for mobile as shown in the quote:

Select Available for Salesforce mobile apps then click Save.

Here is the relevant help page.

You can also test that your url generation is ok by navigating to home, like so:

sforce.one.navigateToURL("/home/home.jsp");
Related Topic