TransWikia.com

JavaScript Error on Custom Button Click

Salesforce Asked on December 24, 2021

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

One Answer

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/

Answered by Kirk B on December 24, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP