function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sunny_mhl10@yahoo.comsunny_mhl10@yahoo.com 

Fields Information on clcik of Custom Button

Hi

 

   I have custom object with 2-3 fields . On click of Custom button on that object i want to get details of information of data entered in that record in an array or json object.

 

Thanks

Best Answer chosen by Admin (Salesforce Developers) 
Navatar_DbSupNavatar_DbSup

Hi,

 

Create a custom button in your object. Follow the below steps:

 

  1. Setup->create->objects->click on your object in which you want to create a custom button
  2. Click on new present in Custom Buttons and Links.
  3. Enter the label and name of the custom button
    Select Display Type= Detail Page Button
    Behavior=execute JavaScript and Content Source=on click JavaScript
  4. Paste the below code in the below area

  {!REQUIRESCRIPT("/soap/ajax/14.0/connection.js")}

 

   var result = sforce.connection.query("Select o.Type, o.StageName, o.Amount, o.AccountId From Opportunity o WHERE o.Id = {!Opportunity.Id}'");

 

   var newOpp = result.getArray("records");

        alert(newOpp);

 

  1. Click on the save button.

After creating the button add the custom button in the page layout.

 

 

 Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

 

 

 

All Answers

Navatar_DbSupNavatar_DbSup

Hi,

 

Try the below code snippet as reference:

 

   {!REQUIRESCRIPT("/soap/ajax/14.0/connection.js")}

 

   var result = sforce.connection.query("Select o.Type, o.StageName, o.Amount, o.AccountId From Opportunity o WHERE o.Id = {!Opportunity.Id}'");

 

   var newOpp = result.getArray("records");

        alert(newOpp);

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

 

  Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

 

sunny_mhl10@yahoo.comsunny_mhl10@yahoo.com

Dear navatar

 

    Where i should write tis code.

 

Thanks

Navatar_DbSupNavatar_DbSup

Hi,

 

Create a custom button in your object. Follow the below steps:

 

  1. Setup->create->objects->click on your object in which you want to create a custom button
  2. Click on new present in Custom Buttons and Links.
  3. Enter the label and name of the custom button
    Select Display Type= Detail Page Button
    Behavior=execute JavaScript and Content Source=on click JavaScript
  4. Paste the below code in the below area

  {!REQUIRESCRIPT("/soap/ajax/14.0/connection.js")}

 

   var result = sforce.connection.query("Select o.Type, o.StageName, o.Amount, o.AccountId From Opportunity o WHERE o.Id = {!Opportunity.Id}'");

 

   var newOpp = result.getArray("records");

        alert(newOpp);

 

  1. Click on the save button.

After creating the button add the custom button in the page layout.

 

 

 Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

 

 

 

This was selected as the best answer