I have a requirement to run case assignment rule from javascript. I used the below code but the assignment rule does not run.


var updateRecord = []; 
var updateCaseRecord=[]; 
var caseToUpdate = new sforce.SObject("Case"); 

if('{!Case.Status}' != 'In Progress' ) {    
    alert('The Case cannot be reversed. A case can be reversed only when it is in "In Progress" Status');  
else {      
    caseToUpdate.id ='{!Case.Id}';
    caseToUpdate.status = '{!Case.Previous_Case_Status__c}';
    assignObj = new sforce.SObject("AssignmentRuleHeader");     
    assignObj.useDefaultRule = 'true';
    sforce.connection.AssignmentRuleHeader = {}
    var result = sforce.connection.update(updateRecord); 
if (result[0].success=='false') {       
else {      
}    //End.  
  • What is the error/issue that you are getting when you execute this code? Commented Oct 13, 2017 at 10:24

1 Answer 1


Looks like AssignmentRuleHeader is case sensitive, Try changing it to assignmentRuleHeader.

Your code would then be:

sforce.connection.AssignmentRuleHeader = {}
sforce.connection.AssignmentRuleHeader.useDefaultRule = "true";

can also be written as:

sforce.connection.assignmentRuleHeader = { "useDefaultRule": "true" }

If this doesn't work, true instead of "true"

sforce.connection.assignmentRuleHeader = { "useDefaultRule": true }

Also you would not want window.location.reload(); at the end outside else, otherwise it would reload after the Status check alert.

  • Changing the AssignmentRuleHeader to assignmentRuleHeader and useDefaultRule= true without quotes did the trick. Thanks for the help! Commented Oct 13, 2017 at 12:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .