- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2017 05:35 AM
Hi there. I have the following requirement: On the cmdb_ci_computer table I have added a new List field called u_users which references the sys_user table. When assigned_to (also references sys_user) changes I want to copy the value to the u_users field, however, I don't want to replace the existing value but rather add to it. What I'll eventually have is a list of users who have been recorded to have used a computer. I also don't want duplicates adding but I figure SN might sort this for me automatically. Any thoughts? This is my current effort:
When: before (Insert and Update)
Condition: [Assigned to] [changes]
(function executeRule(current, previous /*null when async*/) {
current.u_users = current.assigned_to;
})(current, previous);
Thanks
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2017 05:39 AM
UPDATED to filter out duplicates.
I would capture what's already in the field, then add the new person.
Something like this...
(function executeRule(current, previous /*null when async*/) {
var users = current.u_users.split(',');
users.push(current.assigned_to.toString());
users = new ArrayUtil().unique(users);
current.u_users = users.toString();
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2021 12:44 PM
Hi Justin,
I have a similar requirement, To populate "additional assignee list" field with users who updates the incident. But, its weird that it is working fine for very few incidents and not working for many incidents. any input?
(function executeRule(current, previous /*null when async*/ ) {
var currentUserID = gs.getUser().getID();
var users = current.additional_assignee_list.split(',');
if (gs.getUser().hasRole('itil')) {
users.push(currentUserID.toString());
users = new ArrayUtil().unique(users);
current.additional_assignee_list = users.toString();
}
})(current, previous);
Thanks,
Ben.