How to use sforce.one.CreateRecord method?

I’ve a button on visualforce page. On click of that button I want to redirect the user to event/Task creation page. With salesforce, I would have achieved this using global action variable $Action.event.NewEvent. I observed that this do not work on mobile. Can anyone suggest me how to use sforce.one.CreateRecord method in my case.

Answer

From http://blogs.developerforce.com/developer-relations/2013/12/things-to-know-about-s1.html :

Custom navigation via JavaScript: One of the lesser known developer features in Salesforce1 is the ability to navigate users to different places in the app via JavaScript in your Visualforce page. You could for example have a Visualforce page with a ‘New’ button that has the following onClick code.

function createNew() {
      sforce.one.createRecord("My_Custom_Object__c");
}

Clicking the New button will then automatically display the default create/edit page for My_Custom_Object__c inside of Salesforce1. The magical sforce.one object contains a bunch of such navigation utility functions, including the ability to navigate to a record detail view, a user or record feed, an arbitrary URL and more.

A few more details here :
http://blogs.developerforce.com/developer-relations/2013/12/salesforce1-cures-the-app-boogie-fever.html

and the video shortcut :
http://www.youtube.com/watch?v=ZK0cb40f-G4&t=15m18s

Attribution
Source : Link , Question Author : Adroit , Answer Author : altius_rup

Leave a Comment