You need to sign in to do that
Don't have an account?
Custom Sales
List View Custom Button
I am trying to build a button in the list view to:
Change case ownership to the current user
Change the case status to work in progress
I have the following code in the detail page that works fine:
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
var caseObj = new sforce.SObject("Case");
caseObj.Id = '{!Case.Id}';
caseObj.OwnerId = '{!$User.Id}';
caseObj.Status = "Work In Progress";
var result = sforce.connection.update([caseObj]);
window.location.href=window.location.href;
but when I put the button in the list view and click on the button, nothing happens.
it is configured to execute java script as behavior and contentsouce is set to on clickjavascript
Could you guys please provide me some light?
Change case ownership to the current user
Change the case status to work in progress
I have the following code in the detail page that works fine:
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
var caseObj = new sforce.SObject("Case");
caseObj.Id = '{!Case.Id}';
caseObj.OwnerId = '{!$User.Id}';
caseObj.Status = "Work In Progress";
var result = sforce.connection.update([caseObj]);
window.location.href=window.location.href;
but when I put the button in the list view and click on the button, nothing happens.
it is configured to execute java script as behavior and contentsouce is set to on clickjavascript
Could you guys please provide me some light?
Try this code.
{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}
var updateRecord = new Array();
var myquery = "SELECT Id FROM Case";
var result = sforce.connection.query(myquery);
var records = result.getArray("records");
for(i=0; i<records.length; i++ ){
var update_Case = records[i];
update_Case.OwnerId = "{!$User.Id}";
update_Case.Status = "Work In Progress";
updateRecord.push(update_Case);
}
result = sforce.connection.update(updateRecord);
parent.location.href = parent.location.href;
Important :
If this is what you where looking for then please mark it as a solution for others benefits.
Thank You
All Answers
Click your button with the javascript console open, and see if any errors show up. if there are errors, post them here.
Refused to set unsafe header "User-Agent"
Error in event handler for extension.onRequest: undefined Stack trace: undefined
Try this code.
{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}
var updateRecord = new Array();
var myquery = "SELECT Id FROM Case";
var result = sforce.connection.query(myquery);
var records = result.getArray("records");
for(i=0; i<records.length; i++ ){
var update_Case = records[i];
update_Case.OwnerId = "{!$User.Id}";
update_Case.Status = "Work In Progress";
updateRecord.push(update_Case);
}
result = sforce.connection.update(updateRecord);
parent.location.href = parent.location.href;
Important :
If this is what you where looking for then please mark it as a solution for others benefits.
Thank You