+ Start a Discussion
adroITadroIT 

Using sforce.one.createRecord function

Hi,

 

Can you please help on how to use sforce.one.createRecord function. I'm trying to redirect the user to standard new event page using this function on click of a link. But the page simply refreshes. Below is my code. Please help.

 

function createEvent(){
sforce.one.createRecord('Event', null);
}

 

<apex:outputLink  onClick="createEvent()">New Event</apex:outputLink>

adroITadroIT
Hi Gaurav,

Thanks for pointing me to stackexchange post. Actually that post was
created and answered by me (adroIT). The answer is just a work around to
use inline javascript instead of calling a javascript function. Anyways,
Thank you for your kind reply.
kgilkgil
Hey,

Not sure why the JavaScript call from the outputlink isn't working...anyway I just tried this with bypassing the function and called it directly:
 
<apex:page>
    <apex:outputLink  onClick="sforce.one.createRecord('Event');">New Event</apex:outputLink>
</apex:page>

Does this work for you?
kgilkgil
As per a newly noticed error in the Chrome developers console, it appears you are trying to call a JavaScript function used by Salesforce! 
 
<apex:page>
   <apex:outputLink  onClick="banana()">New Event</apex:outputLink>
   <script>
      function banana(){
         sforce.one.createRecord('Event', null);
      }
   </script>  
</apex:page>

Try any other JavaScript function name instead of "createEvent" and it seems to work. Success?
VIVEK 998VIVEK 998
Yes, it works well if you provide any other name for the function!
DoondiDoondi
@Kgil answer worked for me, but I am not able to prepolulate the lookup fields. 
Any sugges how i can accomplish that?