- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2017 09:33 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2017 10:29 AM
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);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2017 11:50 AM
Try the below script. I corrected one line in the display business rule.
- (function executeRule(current, previous /*null when async*/) {
- var usrID = gs.getUser().getID();
- var usrObj = new GlideRecord('sys_user');
- usrObj.get(usrID);
- g_scratchpad.default_group = usrObj.u_default_group;
- gs.addInfoMessage('My group id is '+g_scratchpad.default_group);
- })(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2017 11:54 AM
That did the trick! Thank you both!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2017 11:56 AM
Glad it worked Jason. Can you also mark the question answered to remove it from unanswered list?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2017 11:57 AM
Ignore my previous post. It was not marked answered when I checked. Now it is. Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2017 11:59 AM
Forgot to add the parenthesis to the business rule:
(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);