Friday, January 16, 2015

Enable Visualforce pages for Salesforce1

It's a fairly simple process.  Barring any unsupported stuff on the VF, it should just work.  However I've run in a timeout issue on more than one occasions - clicking on Save ended with a timeout page and the change was never saved.  Had no idea why and didn't have the patience to open a case with Salesforce, so I took the developer route.

Here's how you can work around it if you can use developer tools (or any Metadata API enabled tool for that matter).  The enablement switch is implemented as this availableInTouch field on the ApexPage object.  All is needed is to flip it to true.  For instance if you have Eclipse, you'll notice the field as a member in the page-meta.xml file.

 <?xml version="1.0" encoding="UTF-8"?>  
 <ApexPage xmlns="http://soap.sforce.com/2006/04/metadata">  
   <apiVersion>27.0</apiVersion>  
   <availableInTouch>false</availableInTouch>  
   <confirmationTokenRequired>false</confirmationTokenRequired>  
   <label>MyPage</label>  
 </ApexPage>  

Quick code formatting provided by Source Code Formatter

Once flipped, save it (remember to Save to Server, as Eclipse doesn't build it to server for meta files) and you're all set.  Similarly this can be done with Ant as well.

Please note the field is only available API 27 or later, so make sure the tool connects using supported API versions.