Monday, 3 July 2017

Create records with Java script custom buttons in salesforce.


step1:
Navigate to Setup | Customize | Account | Buttons, Links and Actions
step2:
Press the New Button or Link button
step3:
Give your button a name
step4:
Choose the appropriate Display Type option but in most cases you’ll likely choose a Detail Page Button
step5:
Choose Execute JavaScript as the Behavior
step6:
In the field box you’ll add the JavaScript which I’ll explain below
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
var acct = new sforce.SObject("Account");
acct.name = 'Test Account';
acct.phone = '8147285030';
var result = sforce.connection.create([acct]);
if (result[0].getBoolean("success")) {
window.location = "/" + result[0].id + "/e";
} else {
alert('Could not create record ' + result);
}

Special Note: Dont write require script Like this
               {
              !REQUIRESCRIPT("/soap/ajax/29.0/connection.js")
               }

I hope you enjoyed this post......

No comments:

Post a Comment