2

I am trying to setup a button that will allow one to fire assignment rules on a Case without opening the case. Currently I have a Button Setup that is working that for everything other than the assignmentheader option. I am not sure where to assign it to accomplish this. This will make me look like a RockStar so I am hoping that you guys can help me. Thanks.

The Button is a Detail Page Button with a Behavior of Execute JavaScript OnClick JavaScript... Here is the Code

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

var caseObj = new sforce.SObject("Case");
assignObj = new sforce.SObject("AssignmentRuleHeader");
assignObj.useDefaultRule = 'true';
caseObj.Id = '{!Case.Id}';
caseObj.setOptions(assignObj);

caseObj.IsEscalated = 'true';
caseObj.Status = 'Escalated';
var result = sforce.connection.update([caseObj]);

if (result[0].success=='false') {
alert(result[0].errors.message);
} else {
location.reload();
}

Thanks again for the help. I am sure this is easy but I am newer to JavaScript.

1 Answer 1

0

You can first query the assignment rule Id that you want to set

var assignObj = sforce.connection.query("select id, name from assignmentrule where active='true' and ruletype='assignmentrule' and name='xyz'");
var ruleid = assignObj.getArray("records")[0].get("id");

sforce.connection.AssignmentRuleHeader = {}
sforce.connection.AssignmentRuleHeader.assignmentRuleId=ruleid ;

I have not tried above but i am hoping this is right way to proceed atleast close to solution

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.