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
saad mechiche alamisaad mechiche alami 

Javascript Error when escalating Case to Queue

Hello,

I am currently using the following Javascript Code to assign a case to a queue , by pressing a button called: Escalation to CC I get the attached jpg error message

Here is the code: 

OnClick JavaScript {!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}

var caseObj = new sforce.SObject('Case');
caseObj.Id = '{!Case.Id}';
caseObj.OwnerId = '{!$Setup.Agora_settings__c.CC_queue_ID__c}';
caseObj.Status = "Assigned";
var result = sforce.connection.update([caseObj]);
window.location.href=window.location.href;



User-added image


Can you please help , thanks




 
Vamsi KrishnaVamsi Krishna
can you try changing the last line to window.location.reload();

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

var caseObj = new sforce.SObject('Case');
caseObj.Id = '{!Case.Id}';
caseObj.OwnerId = '{!$Setup.Agora_settings__c.CC_queue_ID__c}';
caseObj.Status = "Assigned";
var result = sforce.connection.update([caseObj]);
window.location.reload();

saad mechiche alamisaad mechiche alami
Hello , and thanks for your comment , I still get the same error message
kiranmutturukiranmutturu
you can try location.reload(true);

or

window.location = '/'+"{!case.Id}";
saad mechiche alamisaad mechiche alami
Hello , thanks Kiran , but the error is still there
kiranmutturukiranmutturu
so its not the error because of that line...
  give an alert statement by including one line after one line i.e.

first 

{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}  give this 
and
put an alert after this --> check alert is displaying or not.. do the same thing by adding each line of your code and add the alert after the line.. you can easily track...
saad mechiche alamisaad mechiche alami
Hello Kiran , I have done an alert in every line of the code , the error is clearly here: 

var result = sforce.connection.update([caseObj]);
window.alert(result)
kiranmutturukiranmutturu
try in this way

!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}

try
{

	var caseObj = new sforce.SObject('Case');
	caseObj.Id = '{!Case.Id}';
	caseObj.OwnerId = '{!$Setup.Agora_settings__c.CC_queue_ID__c}';
	caseObj.Status = "Assigned";
	var result = sforce.connection.update([caseObj]);
}
Catch(ex)
{
	alert(ex + "*******" + ex.message );
}


saad mechiche alamisaad mechiche alami
Hello , 

I get the following error message:

a problem with the on click javascript for this button or link was encountered: unexpected token }
Vamsi KrishnaVamsi Krishna
the RequireScript line is missing {   in the first line at the begining.. please add it and try again..

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

try
{

	var caseObj = new sforce.SObject('Case');
	caseObj.Id = '{!Case.Id}';
	caseObj.OwnerId = '{!$Setup.Agora_settings__c.CC_queue_ID__c}';
	caseObj.Status = "Assigned";
	var result = sforce.connection.update([caseObj]);
}
Catch(ex)
{
	alert(ex + "*******" + ex.message );
}

saad mechiche alamisaad mechiche alami
Hello , i get a pop up message , saying

A Problem with the onClick javascript for this button or link was encountred:
missing catch or finally after try