g_user to get default group ?

hartr
Giga Contributor

I have setup a default support group field against sys_user for all of the ITIL users to record the primary support group that they belong to.

I'd like to use something like

g_form.setValue('assignment_group', g_user.u_default_grp);

or similar so that I can populate the cuurent users default group into the incident.assignment_Group field using a client UI Action.

Does anyone know if this is possible ?

1 ACCEPTED SOLUTION

Here's a better example. If you wanted to modify the assign to me UI Action to include the default group you would use:



current.assigned_to = gs.getUserID();
var myUser = new GlideRecord('sys_user'); //think there's a shortcut but couldn't think of it
if (myUser.get(gs.getUserID())) {
current.assignment_group = myUser.u_default_grp;
}
current.update();


View solution in original post

8 REPLIES 8

john_roberts
Mega Guru

The g_user object is not a true user object, only a limited number of cached properties. You'll have to get the users sys_id from g_user and make a Glide Record query to get the new field value. If possible you should perform this on the server, it will be more efficient than making a server call from the client for this field. However it's certainly possible from the client.


Can you give me a real example ? my scripting skills are basic to say the least .. thanks


Here's a better example. If you wanted to modify the assign to me UI Action to include the default group you would use:



current.assigned_to = gs.getUserID();
var myUser = new GlideRecord('sys_user'); //think there's a shortcut but couldn't think of it
if (myUser.get(gs.getUserID())) {
current.assignment_group = myUser.u_default_grp;
}
current.update();


Thanks John - worked really well..