- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2017 06:47 AM
I need to be able to populate the Populate Assignment Group & Assigned To for service desk staff only. This should not happen to users using the self service portal.
I have experimented with default value: javascript:gs.getUserID() and assignment rules but can not get it working.
any advise/pointers?
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2017 08:53 AM
Is this what you are looking for with an onLoad client script?
function onLoad() {
//Type appropriate comment here, and begin script below
var grp = g_form.getValue('assignment_group');
if (grp == ''){
var userName = g_user.userName;//logged in user
var gr = new GlideRecord("sys_user");//check if the logged in user has a primary group
gr.addQuery('user_name', userName);
gr.addQuery('u_primary_group', '!=', '');
gr.query();
if (gr.next()){//logged in user is a member of assignment group
g_form.setValue('assignment_group', gr.u_primary_group);
g_form.setValue('assigned_to', g_user.userID);
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2017 08:59 AM
And if you want to restrict this to users with a specific primary group, you could change this line:
gr.addQuery('u_primary_group', '!=', '');
to this:
gr.addQuery('u_primary_group', '<specific group's sys_id>');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2017 10:56 AM
Incredible. Thank you so much. This is exactly what i was looking for. I still have a way to go with my JavaScript knowledge so thanks again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2017 12:16 PM
Just one more thing, how would i add an if condition of...
contact_type is not self-service, or contact_type is phone?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2017 01:15 PM
You would need to add another variable to get the value of the contact type, similar to how it checks if the assignment group is empty.
Something like:
var ctype = g_form.getValue('contact_type');
if(ctype == 'phone'){
//add code here
}
OR
if(ctype != 'self-service'){
//add code here
}
The location where you put this 'if' condition will just depend on what you're trying to accomplish.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2018 06:50 AM
Hi,
I know this is an old thread, however i hope you can help, i used your script and it works brilliantly. Is there a way to change it to OnChange? We have rules based on the business service to populate the assignment group, but in the instance where the assignment group is removed and is assigned directly to a person, we want the assignment group to populate with the assigned to primary support group. Is that possible?