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
SteveO1993SteveO1993 

Mimic the Change Status button in a List View

Hi Everyone, I am a little stumped trying to find an answer to this project I am working on.  I was wondering if anyone has a sample source or perhaps point me in the right direction.  The functionality I am trying to achieve is very similiar to the standard "Change Status" button that shows up in a list view of the Lead Entity, however I would like to update a custom field.
 
Here is the breakdown::
 
1. User clicks on specific view of their Leads
2. User selects the leads he/she would like to update
3. User is directed to a followup screen and is presented with a custom picklist field where he/she can apply the value to all selected leads.
4. Click Save
5. User is returned back to the List View
 
 
Below is where I got so far: however I assume I need a URLFOR function to pass the ID's to a custom s control.
 
Any help is appreciated!
Steve
 
Code:
// Include and initialize the AJAX Toolkit javascript library
//
{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")}
// Get the list of job applications that should be closed by using the
// $ObjectType merge field to indicate the type of record Ids that
// are expected.
//
var leadID = {!GetRecordIds($ObjectType.Lead)};
if (leadID == null || leadID.length == 0) {
alert("You need to select Leads to add to the call list.");
} else {
var leadUpdate = new Array();
for (var i = 0; i < leadID.length; i++) {
var callList = new sforce.SObject("Lead");
//
// Since we'll be using the update call, we must set the id
// on the new job application record.
//
callList.Id = leadID[i];
//
//callList.Add_to_Call_List__c = "Marketing";
// Finally add the record to our array.
//
leadUpdate.push(callList);
}
// Now make the update API call in a try statement so we can
// catch any errors. Save the resulting array so we can also
// check for problems with individual records.
//
var callCompleted = false;
try {
var result = sforce.connection.update(leadUpdate);
callCompleted = true;
} catch(error) {
alert("Failed to update Field with error: " + error);
}
// Now check for problems with individual records.
//
if (callCompleted) {
for (var i = 0; i < result.length; i++) {
if (!result[i].getBoolean("success")) {
alert("Job Application (id='" + leadID[i] +
"') could not be updated with error: " +
result[i].errors);
}
}
// Finally, refresh the browser to provide confirmation
// to the user that the job applications were rejected.
//
window.location.reload(true);
}
}

 
 
 
werewolfwerewolf
At the point that you're in this code, you're already in a custom Scontrol.  Why would you need a URLFOR?  Just render your custom picklist and stuff right here, and your Save button, and when the user presses Save then do your thing and redirect the page back to the list view.

Incidentally, inline editing for views that's coming in the Summer release will probably render this moot, because you can mass-change just about any field from any view.  Be sure to turn those on for your users when Summer '08 is released.