Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2024 12:25 AM
Hello All,
I wanted to add the assignment group from change task to change request glidelist field on insert and update. First I need to check values are present or not and then append the new value to the glidelist field. Thanks in advance.
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2024 02:56 AM
Hi @Vikram3
Please try following script
var assignment_group = "679434f053231300e321ddeeff7b12d8"; //mention chg task assignment group
var chg = new GlideRecord('change_request');
chg.addQuery('sys_id', "c83c5e5347c12200e0ef563dbb9a7190"); //mention change sys_id
chg.query();
if (chg.next()) {
var groups = chg.group_list.toString();
var groupList = [];
if (groups != "") {
groupList = groups.split(',');
}
if (groupList.indexOf(assignment_group) == -1) {
groupList.push(assignment_group);
}
chg.group_list = groupList.toString();
chg.update();
}
Thanks,
Swathi
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2024 02:56 AM
Hi @Vikram3
Please try following script
var assignment_group = "679434f053231300e321ddeeff7b12d8"; //mention chg task assignment group
var chg = new GlideRecord('change_request');
chg.addQuery('sys_id', "c83c5e5347c12200e0ef563dbb9a7190"); //mention change sys_id
chg.query();
if (chg.next()) {
var groups = chg.group_list.toString();
var groupList = [];
if (groups != "") {
groupList = groups.split(',');
}
if (groupList.indexOf(assignment_group) == -1) {
groupList.push(assignment_group);
}
chg.group_list = groupList.toString();
chg.update();
}
Thanks,
Swathi
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2024 03:59 AM
Business rule on the change task table:
(function executeRule(current, previous /*null when async*/) {
// Get the Change Request record associated with this Change Task
var changeRequest = new GlideRecord('change_request');
if (changeRequest.get(current.change_request)) {
// Get the assignment group from the Change Task
var assignmentGroup = current.assignment_group;
if (assignmentGroup) {
// Check if the assignment group is already in the Change Request glidelist field
var groupsList = changeRequest.[your_field].toString().split(',');
if (groupsList.indexOf(assignmentGroup.toString()) === -1) {
// Append the new assignment group to the glidelist field
if (changeRequest.assignment_group) {
changeRequest.assignment_group += ',' + assignmentGroup;
} else {
changeRequest.assignment_group = assignmentGroup;
}
changeRequest.update();
}
}
}
})(current, previous);
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark