I am creating a button which creates new record in another object, i am using following javascript code

var curnc= new sforce.SObject("TR_Currency_Approval__c"); 

var result=sforce.connection.insert([curnc]);

if(result[0].success == 'true'){
    alert('An New Opportunity with Name - ' + oppty.Name + ' was Created Successfully.');

I am getting sforce.connection.insert is not a function error, could any one please help me to figure it out


It's actually sforce.connection.create. You'll want to look at the examples in the documentation. Here's the one for create:

var account = new sforce.SObject("Account");
account.Name = "my new account";
var result = sforce.connection.create([account]);

if (result[0].getBoolean("success")) {
  log("new account created with id " + result[0].id);
} else {
  log("failed to create account " + result[0]);
| improve this answer | |
  • Thanks for ur suggestion. error was fixed but record is not creating on click, – prasad nagamalli Mar 2 '17 at 8:59
  • 1
    @prasadnagamalli Check the browser console log for the error. – Saroj Bera Mar 2 '17 at 9:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.