Need Help with New Assignment Rule for Record Producer

Kim5
Tera Contributor

Hello,
I'm trying to set up an assignment rule for my "Create Incident" record producer, but I'm not sure how I can add a variable to the condition. I can't find an option to dot walk there so I've temporarily added keywords are wateridge, but that's not working.

On the record producer itself, I added a variable = building location for when a specific business service is selected, to have the user pick the building location.
When the business service = shipping & receiving and the building location = wateridge than I need it to assign to Assignment Group = Shipping & Receiving - Wateridge.

New Assignment rule conditions:
Record producer is Create Incident
Business Service is Shipping & Receiving
Active is true
NEED TO ADD Variable: Building Location = Wateridge

Consideration: we have another assignment rule for all incidents that come in are assigned to the Help Desk assignment group. The Assignment rule condition for that is simply Active is true and the execution order is 1,000. How can I make sure they work in sync, i.e. one doesn't negate the other? Is it with execution order or do I have to write it into the conditions?

Or if variables won't work here with conditions, can I have a script instead? If so, can you provide an example that I can plug in what I need in?

Thank you, Kim

1 ACCEPTED SOLUTION

Allen Andreas
Administrator
Administrator

Hi,

Within the script section, you would be able to use:

current.variables.variable_name

So for the end-result values of the assignment rule, you would want to use the script section to accomplish the assignment rule execution.

So if...

if (current.variables.variable_a == "apple") {
current.assignment_group = 'sys_id' // or use gs.getProperty('property_name');
}

For execution information:

The order in which the assignment rule is processed. If assignment rules conflict, a rule with a lower-order value takes precedence over a rule with a higher value. If the order values are set to the same number, the assignment rule with the first matching condition takes precedence over the others. Only the first assignment rule with a matching condition runs against a record.

https://docs.servicenow.com/bundle/paris-platform-administration/page/administer/task-table/task/t_A...

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

15 REPLIES 15

Hi,

Please mark my other replies as Helpful, if they are, and if none of them are Correct so far.

Anyways, have you tested what you've tried?

When coding to say 2 conditions must both be true then it's:

if (current.variables.variable_a == "A" && current.variables.variable_b == "B") {
//do x
} else {
//do y
}

More resource here: https://www.w3schools.com/js/js_if_else.asp

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Thank you, Allen. I've tried so many different things and done a ton of tests and I just can't get it to work. I'm going to have to create a support case on this. I really appreciate your time in getting me this far.  

Hi,

I'm sorry you're having trouble...just to confirm what I'm saying is correct. Here's a test record producer I made and it has 4 fields on it:

find_real_file.png

I created this assignment rule:

find_real_file.png

And so this is currently only set for the incident table, with no other conditions specified on the "applies to" tab:

find_real_file.png

This is the end result for the incident:

find_real_file.png

So we see Database group set and the comment is showing as I had it in the assignment rule.

For you, you'd want to verify your "Applies to" tab to ensure the table and any conditions are set properly and that the assignment rule is "active".

You'd then want to check your variable names to make sure they're right and that the values you want are correct.

The rest works as I've mentioned.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Thank you very much, Allen!

Hello again, Allen. I heard back from Support and they said a client script is overriding what you were helping me with a few days ago (re: my "Create Incident" record producer and getting the group to auto-assign when business service = X AND the variable answer = X).

Is it something that could be easily accounted for in the script or is it something that's more complicated that I would have to request for professional services to help me fix? Here is what the script says:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}

// Call to the server to get the default group
var ga = new GlideAjax('cf_DefaultGroup');
ga.addParam('sysparm_name','getDefaultGroup');
ga.addParam('sysparm_user_id', newValue);
ga.addParam('sysparm_current_group', g_form.getValue("assignment_group"));
ga.getXMLAnswer(parseAssignmentGroupResponse);

function parseAssignmentGroupResponse(answer) {
if(g_form.getValue("assignment_group") != answer){
g_form.setValue("assignment_group", answer);
}
}
}