[SalesForce] Link to custom visualforce page from record in salesforce1

I can set it up so my visualforce page is acessible from the side menu, but I would like to be able to link to it from a record as well. Specifically, I need a way to go from an Account page to my custom visualforce page and pass the accountId somehow. Is this in any way possible?

I've tried adding a standardcontroller and calling it through a publisher action, but this adds the cancel and submit buttons in the header that I don't need/want.

Best Answer

You can't do this directly, but you can if you are willing to compromise slightly.

Rather than the publisher action directly opening the target Visualforce page, you can make it open an interim page which then redirects to the standard page using the sforce.one.navigateToSObject method. This exits the publisher 'popup' and displays the target Visualforce page full screen.

The downside is that you have to make two round trips to the server and the user has to wait a little longer.

An example interim page where my target page is 'AccountAndContactsEditV1' is:

<apex:page standardController="Account">
  <h1>Please Wait</h1>
  Redirecting ....
  <script>
    if ( (typeof window.sforce != 'undefined') && (window.sforce!=null) ) {
        sforce.one.navigateToURL('/apex/AccountAndContactsEditV1?id={!Account.id}');
    }
    else {
        alert('Not in SF1 :(');
    }
  </script>
</apex:page>

I've gone into this in more detail with screenshots a blog post at:

http://bobbuzzard.blogspot.co.uk/2014/08/replace-visualforce-buttons-in.html

Related Topic