Issues with assignment rules script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 08:11 AM
Hello,
i have issues with below script for assignment rules. Im unable to push Opened by user into the collaborators field.
Is there any issue with my script?
var myUtils = new util();
var owningGroupID = myUtils.findOwningGroup(current.service_offering.toString());
if (owningGroupID) {
current.assignment_group = owningGroupID;
var collaboratorsListArr = [];
var owningGroupUsersGR = new GlideRecord('sys_user');
owningGroupUsersGR.addQuery('group', owningGroupID);
owningGroupUsersGR.query();
while (owningGroupUsersGR.next()) {
collaboratorsListArr.push(owningGroupUsersGR.sys_id.toString());
}
collaboratorsListArr.push(current.opened_by.toString());
current.collaborators = collaboratorsListArr.join(',');
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 08:19 AM
Hi,
Not sure if you are checking correct table. sys_user_group is the Group table and not sys_user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 08:37 AM
On sys_user I want to query for all of the user that has assigned the group I got from util.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 09:46 AM
@Spike236 Instead of querying on the sys_user, you should query on sys_user_grmember table. The line
owningGroupUsersGR.addQuery('group', owningGroupID);
Update your script as follows and check if it works.
will not work as there is no OOTB group field defined on the sys_user table. However the group field is available on sys_user_grmember table.
var myUtils = new util();
var owningGroupID = myUtils.findOwningGroup(current.service_offering.toString());
if (owningGroupID) {
current.assignment_group = owningGroupID;
var collaboratorsListArr = [];
var owningGroupUsersGR = new GlideRecord('sys_user');
owningGroupUsersGR.addQuery('group', owningGroupID);
owningGroupUsersGR.query();
while (owningGroupUsersGR.next()) {
collaboratorsListArr.push(owningGroupUsersGR.user.sys_id.toString());
}
collaboratorsListArr.push(current.opened_by.toString());
current.collaborators = collaboratorsListArr.join(',');
}
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 11:28 AM
Thank you for the post. Unfortunately its not working.