How to default Assignment Group and Assigned To on Create New Incident form

jlaue
Kilo Sage

Hi All -

I was wondering what is the best way to go about auto-populating the Assignment Group and Assigned To on the Incident form based on the user that is logged in.   For example, I am on the Help Desk, I take a phone call, click on Incident -> Create New, form loads - I want the Assigned To to populate as my UserID and I want the Assignment Group to default to my Default Assignment Group (I have all users set up with a default group in a custom u_default_group field).   I wouldn't want this to take precedence over Inbound Mail Actions, where I would define the Assignment Group there, or for Service Catalog -> Report an Issue, where I could define Assignment Group in that item.  

Thanks in advance!!

J

1 ACCEPTED SOLUTION

ccajohnson
Kilo Sage

Since using the Default value (even with Dictionary Overrides) is not preferrable, you can capture the default group using a Display Business rule, then setting the Assignment group and Assigned to with an onLoad Client Script:



1. Create a Business Rule to capture the Default group value:


Name: Set g_scratchpad for incident


Table: Incident [incident]


Advanced: true


When: display


Script:


(function executeRule(current, previous /*null when async*/) {


      var usrID = gs.getUserID();


      var usrObj = new GlideRecord('sys_user');


      usrObj.get(usrID);


      g_scratchpad.default_group = usrObj.u_default_group;


})(current, previous);



2. Create an onLoad Client Script:


Name: Set Assignments on Create


Type: onLoad


Script:


function onLoad() {


      if (g_form.isNewRecord()) {


              g_form.setValue('assignment_group', g_scratchpad.default_group);


              g_form.setValue('assigned_to', g_user.userID);


      }


}


View solution in original post

10 REPLIES 10

SanjivMeher
Kilo Patron
Kilo Patron

Hi Jason,



For the Service Catalog record producer, you dont know, what will be the assignment group. But if you have a default group you want to set it to, you can use the script field and set it to current.assignment_group = 'the group sys_id';



find_real_file.png



For email, use inbound email script to set it . current.assignment_group = 'group sysid'



On the form you can use onLoad client script to populate the assignment group and assigned to.



Use g_form.setValue('assigned_to',g_user.userID);



To get the assignment group, perform glideajax and pass g_user.userID



Please mark this response as correct or helpful if it assisted you with your question.

Nate23
Mega Guru

you could do an onload client script and a Script inlcude. Use glideAjax to call your script include and have it pass back the "default assignment group" value. then you can set assignment group on the incident form. you can use g_user object to set the assigned to.


ccajohnson
Kilo Sage

Since using the Default value (even with Dictionary Overrides) is not preferrable, you can capture the default group using a Display Business rule, then setting the Assignment group and Assigned to with an onLoad Client Script:



1. Create a Business Rule to capture the Default group value:


Name: Set g_scratchpad for incident


Table: Incident [incident]


Advanced: true


When: display


Script:


(function executeRule(current, previous /*null when async*/) {


      var usrID = gs.getUserID();


      var usrObj = new GlideRecord('sys_user');


      usrObj.get(usrID);


      g_scratchpad.default_group = usrObj.u_default_group;


})(current, previous);



2. Create an onLoad Client Script:


Name: Set Assignments on Create


Type: onLoad


Script:


function onLoad() {


      if (g_form.isNewRecord()) {


              g_form.setValue('assignment_group', g_scratchpad.default_group);


              g_form.setValue('assigned_to', g_user.userID);


      }


}


Thanks Christopher for the detailed explanation and the code!   I am getting the Assigned To to pass through OK, it is not bringing through the Assignment Group, but that may be due to a UI policy on that field or something like that, so I am tinkering with that right now.  



Thanks again!



J