- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2018 01:39 AM
Change would like 'Required Approvals' to be added to a CMR automatically, based on the 'Change Approval Group' attribute on a CI (CI criteria: it is not Non-Operational) this would include CIs that are added to both the primary affected CI variable or or those included as part of the Affected CI TAB).
This is to be applied for both change types: Normal and Emergency (i.e NOT to Standard changes)
Solved! Go to Solution.
- Labels:
-
Change Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2018 02:07 AM
//Add technical approvers to the change request when a new affected CI has been added.
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('change_request');
gr.addQuery('sys_id', current.task);
gr.query();
if(gr.next())
{
var change_grp = gr.u_technical_approvers_group.toString();
if (change_grp.indexOf(current.ci_item.u_change_approval_group) < 0)
{
gr.u_technical_approvers_group = change_grp + ',' + current.ci_item.u_change_approval_group;
}
//Force update to make sure the business rule to calculate risk and the change type will run when new affected CI has been added regardless the CR has
been updated with new approvals.
gr.setForceUpdate(true);
gr.update();
}
})(current, previous);
Harish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2018 01:44 AM
I had the similar requirement here is the script include for that which get called in BR
Script Inlude:
//Add Affected CI change Approval group to Technical Approvers group +',' + tech_app
setAffectedCIApprovals: function(current)
{
//var tech_app = ","+current.u_technical_approvers_group;
var tmp='';// Temporary variable to store value
var gr = new GlideRecord('task_ci');
gr.addQuery('task', current.sys_id);
gr.query();
while(gr.next())
{
tmp+= ','+gr.ci_item.u_change_approval_group; //+',' + tech_app; //change group field in CI
}
var s=tmp;
var s2 = s.split(',');
var uniqueArray = new ArrayUtil().unique(s2);// Comparing array to eliminate duplicate values.
current.u_technical_approvers_group=','+uniqueArray; // field on change form
},
Harish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2018 01:49 AM
Another way is to write after insert BR on Task_ci table
//Add technical approvers to the change request when a new affected CI has been added.
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('change_request');
gr.addQuery('sys_id', current.task);
gr.query();
if(gr.next())
{
var change_grp = gr.u_technical_approvers_group.toString();
if (change_grp.indexOf(current.ci_item.u_change_approval_group) < 0)
{
gr.u_technical_approvers_group = change_grp + ',' + current.ci_item.u_change_approval_group;
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2018 01:51 AM
Thanks for your quick response, first i will try with After insert BR.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2018 01:56 AM
sure. you should have one BR after deletion of CI as well. that will refresh your approvers on deleting the affected CI
after delete BR
(function executeRule(current, previous /*null when async*/) {
//Get the change request record of the affected CI getting deleted
var changeRequestGR = new GlideRecord('change_request');
changeRequestGR.addQuery('sys_id', current.task);
changeRequestGR.query();
if(changeRequestGR.next())
{
SetAffectedCI();
changeRequestGR.setForceUpdate(true);
changeRequestGR.update();
}
//Add Affected CI change Approval group to Technical Approvers group +',' + tech_app
function SetAffectedCI()
{
//var tech_app = ","+current.u_technical_approvers_group;
var tmp='';// Temporary variable to store value
var gr = new GlideRecord('task_ci');
gr.addQuery('task', current.task);
gr.query();
while(gr.next())
{
tmp+= ','+gr.ci_item.u_change_approval_group; //+',' + tech_app;
}
var s=tmp;
var s2 = s.split(',');
var uniqueArray = new ArrayUtil().unique(s2);// Comparing array to eliminate duplicate values.
changeRequestGR.u_technical_approvers_group=','+uniqueArray;
}
Harish