Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm currently working on the navigation between two custom Visualforce Pages inside the Salesforce1 Mobile App. I'm prefer to do the navigation via Apex PageReference.

public static void navigate {
   String str = '\'' + Object.Id + '\')';
   PageReference pageRef = new PageReference(str);
   return pageRef;

But it do not work for me :(


share|improve this question
up vote 2 down vote accepted

I doubt you'll be able to get this to work - the page reference returned from an actionfunction is the URL that the browser should send the user to, so it will be something like an HTTP response code 302 with the target URL in the headers. In that scenario, there is nowhere for the JavaScript to be interpreted and it will simply be taken as a literal URL string.

I tend to handle the navigation client side as I can then take action if the object is undefined, which allows me to use the same pages and controller in Salesforce1, in the full UI and in a custom mobile SDK application.

share|improve this answer

Avoid using Pagereference methods in salesforce1 and usually i would prefer using @Remote action method to implement logic

Lets take a quick look with sample code below on how to achieve this

function actioninvoke(){
   if( (typeof sforce != 'undefined') && (sforce != null) ) {
   // Salesforce1 Remote Action method built in controller

   else {
   //Action Function of normal App

Visualforce Code

 <apex:CommandButton value="Next" onclick="actioninvoke();" id="cmdNext" />

The advantages of remote action will be ability to callback and in callback we can use navigation specific function of salesforce1 like

navigateToSObject(recordId,view)    //Navigates to an sObject record, specified by recordId.view is optional, and specifies the view within record home to select—chatter, related, or   detail.
share|improve this answer
Why should we avoid using PageReference methods in Salesforce1? – RobAlexander Aug 12 '14 at 19:07
You dont want the whole page refresh ?Have you seen SPA mobile apps ,they dont prefer whole page refresh – Mohith Shrivastava Sep 16 '14 at 4:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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