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
Masie MaseliMasie Maseli 

Custom Javascript button invoke standard functionality

Hi all

I have custom list view button that changes a record's ownership to the current user. I want to find out if it is possible to have the button open the standard change owner screen? 
SarfarajSarfaraj
Hi Masie

The relative url to standard change owner screen is
/<record id>/a
Let me know if you need any more illustration.
--Akram
Masie MaseliMasie Maseli
Hi Akram

I definitely need more illustration as I have been trying and I am just not getting it right. I have pasted my current javascript below.

{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")}
var url = parent.location.href; 
var records = {!GETRECORDIDS($ObjectType.Account)};
var updateRecords = [];

if (records[0] == null) { 
    alert("Please select at least one record to update.");  
} else { 
    for (var a=0; a<records.length; a++) { 
        var update_Account = new sforce.SObject("Account"); 
        update_Account.Id = records[a]; 
        update_Account.OwnerId = "{!$User.Id}"; 
        updateRecords.push(update_Account); 
    }
    result = sforce.connection.update(updateRecords);
    parent.location.href = url; //refresh the page
}
SarfarajSarfaraj
Masie,

Thanks for the code. As I can see you are changing owner of multiple records at a time.
But standard change owner screen is for one record at a time. It is very much possible to open the standard change owner screen, but it will work only for one record. 

--Akram
Masie MaseliMasie Maseli
Thanks- I wanted to button to act the way the standard change owner button on leads work.
SarfarajSarfaraj
Okay. Now I understand your requirement. No this is not possible. That standard page is for Lead only. What you have to do is to create a new VF page with similar functionality. Here is one example code on how to write this kind of VF,
http://www.salesforce.com/docs/developer/pages/Content/pages_quick_start_massupdate.htm

--Akram