[SalesForce] salesforce1 navigateToURL issues

I've got a VisualForce page that is enabled for Mobile; it uses Opportunity as its StandardController, and I've created a custom action on the Opportunity object that uses this action. I then enabled the Chatter feed and dropped this action into the publisher. Now, in SF1, when I go to an opportunity, I can see my custom action, but when I click on it, there are issues. The page has the following Javascript in it:

    <apex:page standardController="Opportunity">
    <script type="text/javascript">
    setTimeout(function() {
        var myURL = '/apex/MyPage?oid={!Opportunity.Id}';
        if(typeof sforce != 'undefined' && sforce != null) {
            sforce.one.navigateToURL(myURL + '&isdtp=p1');
        } else {
            document.write("Not enabled except for mobile.");
        }
    }, 1);
    </script>
    Redirecting...
    </apex:page>

I found a reference to the isdtp querystring variable in another post, and when I use it, SF1 redirects me to my webtab. If I remove that querystring variable, I am not redirected at all, there is no error, and there's nothing in the console. The issue is that I want to pass the opportunityID that I'm currently on to MyPage, and when I have the isdtp variable in the querystring, it strips off the oid querystring variable before it gets to MyPage. My preference would be to not use the isdtp querystring variable, because I think it's a hack.

Does anybody have any suggestions?

Best Answer

Thanks for the response CaspNZ, and I'm not sure what was going on yesterday, but today I was able to remove the isdtp and it still redirected. However, my querystring parameters still weren't being passed to my application. For future reference, here's what I did to figure this out.

  1. I scraped my user agent for my mobile device in SF1 and used it in Chrome. I was then able to see the app in a full browser.
  2. I stepped through the code and could see that the app is using an anchor tag, which I realized was just base64 encoded. When I decoded the string, it turns out to be JSON which includes my original requested URL.
  3. I was then able to scrape out the original querystring parameters in my target VF page.

Thanks again, Jim

Related Topic