2

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?

2

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");
  • The page is already enabled for mobile. I will test navigating to the home page tomorrow. – Jagular Aug 21 '14 at 3:04
2

Groan. I thought I was up against some sort of subtle escaped quote issue. I wasn't. When I corrected

'javascript:sforce.one.navigateToUrl(\''+ apexstr + warehouse.Id + '\')';

to

'javascript:sforce.one.navigateToURL(\''+ apexstr + warehouse.Id + '\')';

navigation to the apex page worked. I've guess I've gotten sloppy about spelling functions exactly right from working with languages that don't care about case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.