You need to sign in to do that
Don't have an account?
VSK98
Can anybody pls share the sample code for Selected list view from javascript using button
Hi All,
Can anybody pls share the sample code for Selected list view from javascript using list view button
Can anybody pls share the sample code for Selected list view from javascript using list view button
I hope it will give clear
Feel free to ask again
Adv thnx
Siv
For this i created one list view button with Execute JavaScript and place it in Search Layouts (Leads Listview).
Step1:
Go to leads ==> Click on Buttons,Links and Actions ==> Click on New Button or Link.
JavaScript Code to paste in the Window.
//adds the proper code for inclusion of AJAX toolkit
{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")}
//string for the URL of the current page
var url = parent.location.href;
//grabs the Lead records that the user is requesting to update
var records = {!GETRECORDIDS($ObjectType.Lead)};
//array for holding records that this code will ultimately update
var updateRecords = [];
//if the button was clicked but there was no record selected
if (records[0] == null) {
//alert the user that they didn't make a selection
alert("Please select at least one record to update.");
} else { //otherwise, there was a record selection
for (var a=0; a<records.length; a++) { //for all records
//create a new sObject for storing updated record details
var update_Lead = new sforce.SObject("Lead");
//set the Id of the selected Lead record
update_Lead.Id = records[a];
//set the value for Status to 'Unqualified'
update_Lead.Status = "Unqualified";
updateRecords.push(update_Lead);
//add the updated record to our array
}
//push the updated records back to Salesforce
result = sforce.connection.update(updateRecords);
parent.location.href = url; //refresh the page
}
Step 2 :
Click on Save.
Step 3:
Go to Leads Object==> Search Layouts==>Edit Leads List View==>Select the Newly created list view button and save.
Step 4:
select the Lead you want to update and click on the Button. Then selected Leads were updated with Unqualified Status...