- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-16-2022 02:04 PM
We have several risk conditions defined in our instance which are working to initially set the risk on a Change. We have requirements internally that if specific CIs get added as affected CIs then the risk of the change should be updated. Essentially these CIs are CIs that also get picked up by the risk conditions. In this way if someone opens a low risk CI and adds a high risk CI as an affected CI the change risk should be elevated.
Looking at the RiskCalculator script include it seems that it is expecting a change record to be passed in and therefore only takes into the account the CI on the change. Is there an OOB script include that can be used to evaluate an affected CI against the risk conditions? In this way I could write a BR which evaluates the risk conditions every time an affected CI is added or removed from the affected CI list. If the affected CI has higher or lower risk than the change CI I can take action to updated the change risk.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2022 02:06 PM
Sadly the OOB script include which runs a change through the risk conditions requires that you pass the change into the call. Therefore you can't write a BR to check what the risk would be on each of the affected CIs. To solution this I had to write a BR which loops through all of the affected CIs and validates them against the risk condition filters. Not terrible but a little bit work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-16-2022 03:56 PM
I have tried this but it's not working. Always returns risk of low. I think the problem is how I am trying to get the risk calculator to run change glide record through the risk conditions.
(function executeRule(current, previous /*null when async*/) {
var changeSysID = current.task;
var gr1 = new GlideRecord('change_request');
gr1.get(changeSysID);
//Get the current risk value
var risk = gr1.risk;
//Find all affected CIs
var gr = new GlideRecord('task_ci');
gr.addQuery('task', changeSysID);
gr.query();
while(gr.next()){
var ciSysId = gr.getValue('ci_item');
//create a change glide record
var gr2 = new GlideRecord('change_request');
//set the configuration item to the affected ci
gr2.setValue('cmdb_ci', ciSysId);
//I think the problem is here, not sure I can just pass a glide record into this function. Does it need to be an existing change record?
var riskCalculator = new RiskCalculator(gr2);
var evaluatedRiskImpact = riskCalculator.setDryRun(true).evaluateRiskImpact();
gs.addInfoMessage("CI: " + gr.getDisplayValue('ci_item') + " Risk: " + evaluatedRiskImpact.riskEvaluation.risk.value);
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2022 02:06 PM
Sadly the OOB script include which runs a change through the risk conditions requires that you pass the change into the call. Therefore you can't write a BR to check what the risk would be on each of the affected CIs. To solution this I had to write a BR which loops through all of the affected CIs and validates them against the risk condition filters. Not terrible but a little bit work.