
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2021 10:27 AM
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
Solved! Go to Solution.
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2021 10:32 AM
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.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2021 02:31 PM
Oops...the tech also said this:
The Client Script populates the Assignment Group field from the value it gets from calling the Script Include. You can modify the Client Script so that it only populates the Assignment Group field with your desired value, or you can modify the Script Include so that it returns the correct value for Assignment Group.
Here is the Script Include:
var cf_DefaultGroup = Class.create();
cf_DefaultGroup.prototype = Object.extendsObject(AbstractAjaxProcessor, {
// Returns the Default group for the given user. If not set just return the first group found
getDefaultGroup: function(user_sys_id) {
var user_id;
// If the user_sys_id is not passed in directly, get it from the GlideAjax parameter
if(user_sys_id == null){
user_id = this.getParameter('sysparm_user_id');
} else {
user_id = user_sys_id;
}
// Check for a current group to see if we need to validate membership
var current_group_id = this.getParameter('sysparm_current_group');
this.debug("Getting default group for user: " + user_id + ", group (opt): " + current_group_id, "getDefaultGroup");
// Initialize return variable with default
var default_group = false;
//Check to see if user is a member of the current group for client-side use
if(current_group_id != undefined) {
//Query to see if the user is a member of the current group
var current_group_record = new GlideRecord('sys_user_grmember');
current_group_record.addQuery('user', user_id);
current_group_record.addQuery('group', current_group_id);
current_group_record.query();
if(current_group_record.next()) {
this.debug("User is a member of the given group", "getDefaultGroup");
default_group = current_group_record.getValue('group');
}
}
if(!default_group) {
// Query for the user
var user_record = new GlideRecord('sys_user');
if(user_record.get(user_id)) {
if(!user_record.u_default_group.nil()){
// Use the Default Group from the user record if it is populated
this.debug("Returning group from user record: " + user_record.u_default_group.getDisplayValue(), "getDefaultGroup");
default_group = user_record.u_default_group;
} else {
// Grab one of the assignment groups for the user
var group_membership = new GlideRecord('sys_user_grmember');
group_membership.addQuery('user', user_id);
group_membership.orderBy('group.u_order');
group_membership.query();
if(group_membership.next()){
this.debug("Returning first group from membership: " + group_membership.group.getDisplayValue(), "getDefaultGroup");
default_group = group_membership.group.sys_id;
}
}
}
}
//gs.log("Default Group for: " + user_id + " is " + default_group);
if(default_group){
return default_group;
}
},
// Returns the groups that the user is a member of
getUserGroups: function(user_sys_id){
this.debug("Getting groups for " + user_sys_id, "getUserGroups");
// Query for the user groups
var grpArr = [];
var rec = new GlideRecord('sys_user_grmember');
rec.addQuery('user', user_sys_id);
rec.query();
while(rec.next()){
this.debug("Adding group: " + rec.group.getDisplayValue(), "getUserGroups");
grpArr.push(rec.group.sys_id.toString());
}
return grpArr.join();
},
/*
* Logs debug info prefixed with the hours, minutes, seconds, and milliseconds if debugging is turned on
*/
debug: function(txt, source_suffix){
if(this._debug_on == undefined){
if(gs.getProperty("cf.default_group.debug", 'true') == "true"){
this._debug_on = true;
} else {
this._debug_on = false;
}
}
if(this._debug_on){
this.log(txt, source_suffix);
}
},
/*
* Function that logs the given string prefixed with the minutes, seconds, and milliseconds
*/
log : function(txt, source_suffix) {
var source = this.type;
if(source_suffix != undefined){
source += '.' + source_suffix;
}
var d = new Date();
var time = this.pad(d.getHours()) + ':' + this.pad(d.getMinutes()) + ':' + this.pad(d.getSeconds()) + '.' + this.pad(d.getMilliseconds(), 3);
gs.log(time + ' - ' + txt, source);
},
pad: function (num, digits){
// default to 2 if not passed in
if(!digits){
digits = 2;
}
num += '';
while(num.length < digits){
num = '0' + num;
}
return num;
},
type: "cf_DefaultGroup"
});

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2021 02:54 PM
Hello,
As I've demonstrated above in my replies, please always use the forum feature: "Insert/Edit code sample" when pasting code. Otherwise, it's just a wall of text and is unorganized and hard to read:
As a side question to all this, do you all not have a ServiceNow trained employee with your organization? They may be able to help a bit more with this.
As far as any client script overriding what you're doing, you can simple disable the client script if it's not needed. You manually adjusting it with your value, is essentially the same as overriding it anyway. Please try that first and foremost and see if that works for you.
I'm don't have the full context as to why that client script is there, etc. But if you're trying to use assignment rules and other functionality then disable it. This is a customization, I believe, on your end and not SN specific to base line settings.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2021 03:16 PM
Ah! I wasn't familiar with that. Thank you. I will definitely use that in the future if I need to paste the code. No, I'm trying to learn on my own, which is difficult, and if I can't figure it out, I have to engage with a third party to help me. If they help, I don't really get to learn. I'll try disabling it and see what happens. If it doesn't work, I'll definitely reach out to our third party for help. Thanks, again, for your time, Allen.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2021 03:18 PM
Hello,
Alright, glad it was helpful.
Take care!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2021 02:37 PM
Adding my solution to close the loop for anyone else that reads through all the comments on this (because it may help someone else out there like me). Instead of creating assignment rules for this (Now support) suggested we add script directly into the record producer itself.
In my record producer (mine was "Create Incident"), I clicked on the "Generated Record Data" tab and added the following script:
//If Building Location is "Wateridge" and Business Service is "Shipping & Recieving". Assign to 'Shipping & Receiving - Wateridge' Group
if(producer.please_select_the_location_where_services_are_needed == 'wateridge' && producer.cmdb_ci == 'c654fed2dbce6740627ff8f3399619f6'){
current.assignment_group = '736f7926db61f8101d51ff0968961922'; //Shipping & Receiving - Wateridge Group
}
// //If Builing Location is "Wateridge" and Business Service is "Facilities & Services". Assign to 'Facilities Operations - Wateridge' Group
if (producer.please_select_the_location_where_services_are_needed == 'wateridge' && producer.cmdb_ci == '15ea90c5dbbda700627ff8f3399619cd') {
current.assignment_group = '6e3efda2db61f8101d51ff0968961914'; //Facilities Operations - Wateridge Group
}