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
Joanna Moya 9Joanna Moya 9 

Update Status and Checkbox on Case button?

Hello Developer Friends, I am trying to create a list view button that will mark a case as Spam (custome checkbox field) and Update the Case Status to Resolved. The below is what I've got but I know it is worng. Any help is appreciated!

Thank you and be well!

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

var record = new sforce.SObject("Case");  

c.Is_Spam__c = 'true';
caseObj.Status = 'Resolved';
record.Id = "{!Case.Id}";


var result = sforce.connection.update([record]);
window.location.reload();

 
PrabhaPrabha
You Need to loop through all the records, try this sample:
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 

var records = {!GETRECORDIDS($ObjectType.Case)};

var newRecords = [];

for (var n=0; n<records.length; n++){

var c = new sforce.SObject("Case");
c.id = records[n];

c.Is_Spam__c= 'true';

newRecords.push(c);
}
result = sforce.connection.update(newRecords);
window.location.reload();
HTH,
PrabhaN