+ Start a Discussion
chiranthchiranth 

Custom Button:Below code is working in detail button but not working in list button.

Hi the below code is assinging the case to the loged in user . It works fine when the detail button is created with the javascript code but its not working when the list button is created with the same code[It will enter the else loop].

 

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

var caseid = "{!Case.Id}"; 
var userid = "{!$User.Id}"; 
var CaseToUpdate = new sforce.SObject("Case"); 
CaseToUpdate.set("Id", caseid); 
CaseToUpdate.set("OwnerId", userid); 
var Result = sforce.connection.update([CaseToUpdate]); 
if(Result[0].getBoolean("success")) 

function redirect() { parent.frames.location.replace("/{!Case.Id}"); } 
redirect(); 

else { 
alert("Error"); 
}

 

 

 

Please help me on this

Thanks

Best Answer chosen by Admin (Salesforce Developers) 
RoyGiladRoyGilad

I'm glad I could help, please mark as resolved for future generations :)

Have a great day!

 

All Answers

RoyGiladRoyGilad

Hi,

When you are in list button the line:

"var caseid = "{!Case.Id}"; "

has no meaning.

 

You need to use the list view methuds of getting IDs:

{!GETRECORDIDS(  $ObjectType.Case)};

 

I hope that helps,

Roy Gilad

 

chiranthchiranth
Thanks it work's. Thanks and Regards, __________________________________________________________________________________________________________________________________________________________________________ Chiranth Aradhya ______________________________________________________________________ Disclaimer:This email and any attachments are sent in strictest confidence for the sole use of the addressee and may contain legally privileged, confidential, and proprietary data. If you are not the intended recipient, please advise the sender by replying promptly to this email and then delete and destroy this email and any attachments without any further use, copying or forwarding
RoyGiladRoyGilad

I'm glad I could help, please mark as resolved for future generations :)

Have a great day!

 

This was selected as the best answer