Created
May 19, 2017 16:44
-
-
Save kcimpulse/c16dd028b5681aabb5c62cf7251a0ecf to your computer and use it in GitHub Desktop.
ServiceNow - Script Includes - Backfill Assignment Group if user is selected first. & Update to Task Table, Assignment Group Refrence Field
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var BackfillAssignmentGroup = Class.create(); | |
| BackfillAssignmentGroup.prototype = { | |
| initialize: function() { | |
| }, BackfillAssignmentGroup:function() { | |
| var gp = []; | |
| var a = current.assigned_to; //sys_user_grmember has the user to group relationship | |
| var grp = new GlideRecord('sys_user_grmember'); | |
| if(a){ | |
| grp.addQuery('user',a); | |
| } | |
| grp.addEncodedQuery("group.typeLIKEcff624593854010072edffb4849a2c4a"); //Set to your Group SID Type to limit amount of Groups. | |
| grp.query(); | |
| while (grp.next()) { | |
| gp.push(grp.getValue('group')); | |
| } | |
| // return Groups where assigned to is in those groups we use IN for lists | |
| return 'sys_idIN' + gp.join(','); | |
| }, | |
| type: 'BackfillAssignmentGroup' | |
| }; | |
| // Below is the Advanced Reference Qualifier for the Task Table Assignment Group Refrence Field - With No Attributes Needed. | |
| javascript:new BackfillAssignmentGroup().BackfillAssignmentGroup() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment