2

I have a visual flow and I added jQuery to handle a click event on the finish button that calls sforce.one.navigateToURL(). The goal is to direct a user to a detail page once the flow is complete. It works well when I hard code a value for the ID, but when I use the PageReference reference variable it's just a blank screen in the Salesforce1 app. I also tried passing the variable to the finishLocation flow attribute, but I get the same results. What am I missing? Is there another possible solution I can explore?

2

Just looking at some standard documentation, it does not look like a fruitful line of pursuit:

When developing Visualforce pages for the full site developers can utilize the Page Reference class to control the navigation. This method is not supported in Salesforce1 and may not work as expected. Some pages will load using Page References however this may change with any update and should not be relied on. Salesforce Support is unable to troubleshoot issues that arise from using a Page Reference for navigation in Salesforce1.

A good starting point is Managing Navigation in Salesforce1. The best case is if you have a record Id to work with. With that you can use sforce.one.navigateToSObject. Failing that, you can provide a fallback url to the sforce.one.navigateToURL method as mentioned in your OP.

if (recordId) sforce.one.navigateToSObject(recordId);
else if (redirectUrl) sforce.one.navigateToUrl(redirectUrl);

Specifically with a PageReference you can theoretically do:

sforce.one.navigateToUrl(myPageReference.url);
  • What would you recommend? Is there anything specific for Salesforce1? I'm not sure how to proceed. – VanAlfredo Jan 29 '16 at 0:57
  • @VanAlfredo See my additions. – Adrian Larson Jan 29 '16 at 1:20
  • Thanks. How do I get the current record Id without using a PageReference? I need it to be dynamic. @AdrianLarson – VanAlfredo Jan 29 '16 at 15:55
  • @VanAlfredo That seems like a different question to me. If you are in an extension you can cache controller.getId() in your constructor. – Adrian Larson Jan 30 '16 at 17:52
  • 1
    You're right! That's what I ended up doing. @AdrianLarson. I used that to pass to the navigateToSObject method and also passed it to the finishLocation flow attribute, so it works on the full site as well. – VanAlfredo Jan 30 '16 at 18:03

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.