client script for category and subcategory assignment
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2010 11:33 PM
Right now in our service-now instance, if you create an incident and choose a category called 'Accounts' , the inc get assigned to the group 'Desktop'
automatically throught.
I am writing a client script to assign the inc to the group 'DBA' if the category is 'Accounts' and the subcategory is 'Oracle' .
My script is partially working but after my script assign the inc to 'DBA' , the assigned_to field doesn't allow dropdown suggestion anymore.
Can someone help?
Here is my script
Type: OnChange
Table: Incident
Field Name: Subcategory
function onChange(control, oldValue, newValue, isLoading)
{
//If the page isn't loading
if (!isLoading)
{
//If the new value isn't blank
if(newValue != '')
{
//Type appropriate comment here, and begin script below
var cat_field = document.getElementById('incident.category');
var cval = g_form.getValue('category');
if ( cval == "Accounts & Passwords" )
{
if ( newValue == "Oracle" )
{
g_form.setValue('assignment_group', 'DBA');
}
}
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2010 03:30 PM
Here is the problem
In our assignment rules we have
Name: DBA
Table: Incident Group:DBA
Category is DBA
------------------------------
Name: Help desk
Table: Incident Group: Help desk
Category is Accounts & Password
-------------------------------------------------
The ajax assignment script will assign to a particular group based only on the category.
In my case I want to kind of over write the Helpdesk assignment rule to assign to DBA if the SUBCATEGORY is 'Oracle' , otherwise leave the assignment to help desk.
I don't think if I change the DBA assignment rule to look like this
Name: DBA
Table: Incident Group:DBA
Category is DBA
or Category is 'Accounts & Password'
and Subcategory is 'Oracle'
This is will cause the DBA category not assignment to DBA anymore.
The way it is right now(before my client script) assignment rule work on category to group and the assigned To entry only allow to pick from users from that list.
My client script work but it will not show any user in the DBA group.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2010 06:18 AM
I think the piece that you're missing is that the AJAX assignment script should run on change of category AND subcategory. Your assignment lookup table should hold all of the possible category/subcategory combinations that you want to handle assignments for.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2010 06:48 AM
Setting a reference field (like assignment_group) in a client script requires the sys_id value rather than the name of the group. In order to get that using a client script you have to query for it. There is a solution that you can set up in your instance that leverages the assignment lookup functionality in Service-now but allows you to see the assignments instantly. Details can be found here.
http://www.servicenowguru.com/system-definition/assignment-rule-lookup/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2010 11:18 PM
Mark,
Setting the assignment_group to the sys_id value works.
I now have this
g_form.setValue('assignment_group', '3529a78c0a0a3c7e00691728b3f6bb89');
instead
g_form.setValue('assignment_group', 'DBA');
But I've cheated to get the sys_id by printing the sys_id of DBA in another script, capture it and used it here.
Thanks a lot for your help