- 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 07:00 AM
Generally Service Desk users are member of service desk group. So instead of javascript:gs.getUserID() put a script include here and check if the user isMemberOf() service desk then set assignment group and assigned to.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2017 07:15 AM
interesting idea... when you say populate do you mean reassign to them or only on new records??
Either way it seems like the best way to do this is on the client side... it is fairly easy to disable the SP view that way set the client script to only run on desktop <not mobile>
Since glide queries are NOT recommended inside a client script we would be better off grabbing the assigned to and their group BEFORE we load the record store em in the scratchpad and then we won't have to do any queries on the record...
so you are going to make an on display BR for the table and set scratchpad variables for them...
so in that display rule on whichever table this is for...<this is pseudo code i wrote on the fly>
//we are going to grab the user no matter what.. .then set a flag to tell the record if it needs to auto assign it and if so to which group i built this for a single group but by putting in an array of groups instead of one you can set auto assign for multiple groups easily
g_scratchpad.usr_sid = gs.getUser();
g_scratchpad.auto_assign = false; //if this is an auto assign group we will set this to true and use it on the record.
var grp_to_assign = ''; // put in the sys id of the group/groups you want to auto assign for... a preferred method would be to make a sys property for this and fetch it
//now we need to get the group .. we will just get the first one they are in and then compare to groups we auto assign for
var grp = new GlideRecord('sys_user_grmember');
grp.addQuery('user',g_scratchpad.usr_sid);
grp.query();
if (grp.next()){
if(grp.group == grp_to_assign){
g_scratchpad.assign_group = grp.group;
auto_assign = true;
}
}
__________________________________
now on the client script on load check the auto assign and if it is true .. and other conditions are met .. <only for new records.. assignment group is blank etc> are true... set the assigned to and assignment group based on the scratchpad values.. to access them you just use g_scratchpad
so for example...
g_form.setValue('assigned_to',g_scratchpad.usr_sid.);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2017 08:21 AM
Hi thanks for the speedy response. The assigned to and assignment group should populate onLoad before the record is saved or submitted, The assignment group should be the same as the Primary Group (u_primary_group) field set on the User (sys_user) table. If no primary field is set, the form would not pre-populate.
- 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);
}
}
}