Custom Salesforce Button to Execute JavaScript


  1. From Setup in your DE org, click Create | Objects and Select any one on which you wants custom button.
  2. Scroll down to the Buttons, Links, and Actions section and click New Button or Link.
  3. In the Label field, enter "label name".
  4. For Display Type choose Detail Page Button.
  5. For Behavior choose Execute JavaScript.
  6. For Content Source choose OnClick JavaScript.
Notice that you are creating a Detail Page button that executes some JavaScript. For your convenience, here is the JavaScript example code that you can copy and paste into the form: 
  
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}

sforce.connection.sessionId = '{!$Api.Session_ID}';     
var result = sforce.connection.describeSObject("Contact");
for (var i=0; i<result.fields.length; i++) { 
var field = result.fields[i];
alert(field.name);
}

No comments:

Post a Comment