I have a custom button on my accounts list view to change the record from the current owner to my ownership using OnClick Javascript. I have admin privileges and when I use the button it succeeds in changing the ownership to me. However, when I try to change the ownership as another user the record does not change ownership. I have ensured that the profiles of the users attempting to make the change have the system permission to change the record owner or transfer records. Any help is appreciated. The code used was as follows:


var accountIds = {!GETRECORDIDS($ObjectType.Account)}; 
var account = [], tempAccount, result; 

while(accountIds.length) { 
tempAccount = new sforce.SObject('Account'); 
tempAccount.Id = accountIds.shift(); 
tempAccount.OwnerId = '{!$User.Id}'; 
result = sforce.connection.update(account); 
window.top.location.href = window.top.location.href;
  • 2
    you can try to output result to see what kind of errors are happening during update
    – kurunve
    Apr 15, 2016 at 15:37
  • please console.log(accountIds) and see what your values are.. Apr 15, 2016 at 15:40

1 Answer 1


You probably have custom validation or trigger, which doesn't allow you to update record.

You could try to debug javascript errors if add after

result = sforce.connection.update(account); 


for(var i=0;i<result.length;i++){
  console.log("account updated with id"+result[i].id);
  console.log("failed to update account"+result[i]);

You should see Alert and you can find full debug in browser console.

  • {!GETRECORDIDS($ObjectType.Account)} returns Ids
    – o-lexi
    Apr 15, 2016 at 17:14
  • I have empty array at custom list view page Apr 15, 2016 at 17:29
  • Did you check some records? - these are going to be submitted.
    – o-lexi
    Apr 15, 2016 at 17:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .