I have created a custom button with some custom code , Although it is not working as designed:
Code used:
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
var newRecords = [];
var existingRecordType = "{!Case.RecordType}";
var c = new sforce.SObject("Case");
c.Id ="{!Case.Id}";
c.OwnerId="{!User.Id}";
if (existingRecordType == "Queue") {
var result = sforce.connection.query("Select Id From RecordType where name='Accept' ");
var records = result.getArray("records");
if(records.length > 0){
var Id = records[0].Id;
c.RecordTypeId=Id;
c.Status = "In Process";
}
}
if (existingRecordType == "Internal Case - Queue") {
var result1 = sforce.connection.query("Select Id From RecordType where name='Internal Case' ");
var records1 = result1.getArray("records");
if(records1.length > 0){
var Id1 = records1[0].Id;
c.RecordTypeId=Id1;
c.Status = "In Process";
}
}
newRecords.push(c);
result = sforce.connection.update(newRecords);
window.location.reload();
This button is designed to change the case owner
I am getting the following error in chrome console [Report Only]
Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src https: 'unsafe-inline'".