1

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'".

0

Try setting: Content-Security-Policy: script-src 'self'

Here is a detailed tutorial on setting this directive.

http://www.html5rocks.com/en/tutorials/security/content-security-policy/

  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review – Himanshu Jan 12 '16 at 17:13
  • Here is the essential part: Try setting: Content-Security-Policy: script-src 'self' – Kirk B Apr 13 '16 at 21:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.