- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-23-2018 01:08 AM
Hi All,
Does anyone have implemented a solution for Change Management that they won't be able to move the change for approval unless they have completed the Risk Assessment (plugin is activated)? So it's like the change is submitted but once they click on the 'Request for Approval' button is should say something like you have not completed the risk assessment yet and will abort.
Any help is appreciated.
Thanks,
Ramel
Solved! Go to Solution.
- Labels:
-
Change Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2018 02:53 AM
Hi Ramel
Sure you can put the query into the ui action, you just need to ensure that you have an If statement that has a query in it to query for the existence of an assessment and if it does find one proceed with the original content of the ui action.
The alternate condition if it doesn't find an assessment is to pop the info message and redirect to the current.
It's a good idea to create a new ui action and then mark the ootb one inactive, this is better than modifying the ootb one as that will stop later updates and improvements from SN deploying to it.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-23-2018 02:02 AM
We use an on before business rule on the change request table
on update only
filter condition of state is one of Assess or Authorize
and
Retrospective is false
we have a boolean called u_risk_assessment_taken that is not seen on the form
(function executeRule(current, previous /*null when async*/) {
var risk_taken = current.u_risk_assessment_taken;
if (risk_taken == false){
current.state = previous.state;
gs.addInfoMessage(gs.getMessage('Please complete the risk assessment before progressing this change for approval'));
current.setAbortAction(true);
}
})(current, previous);
then in the execute risk calculation ui action
var scr = new RiskAssessmentCalculator();
var takenRA = '';
var assessmentMatch = scr.checkForMatchingAssessment(current.sys_class_name, current);
if (assessmentMatch == '') {
calcRisk();
}
else {
takenRA = scr.checkForAssessmentInstance(current.sys_id);
//the correct assessment has been taken
if (takenRA != '' && takenRA == assessmentMatch){
calcRisk();
}
if (takenRA != '' && takenRA != assessmentMatch){
gs.addInfoMessage(gs.getMessage('Incorrect risk assessment taken, please fill out a new assessment'));
}
if (takenRA == ''){
gs.addInfoMessage(gs.getMessage('A risk assessment is required, please fill out a risk assessment'));
}
}
function calcRisk() {
var risk = scr.calculateRisk(current);
current.u_risk_assessment_taken = true;
current.update();
}
action.setRedirectURL(current);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-23-2018 02:21 AM
Thanks for the response Scott.
I do not see the 'execute risk calculation' UI action, is it the 'Calculate Risk' button in Kingston? Or should I just create a new UI action with the suggested code and deactivate the OOTB?
Regards,
Ramel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-23-2018 02:31 AM
Hi Ramel
I am on Kingston also but it's been upgraded many times to get here so it's still got old functionality in it.
In our change module there are 2 actions
Fill out Risk assessment - This gives you the pop up box with questions depending on conditions. For us we are using Business Service category but you could use others
Then there is a second one that does execute risk calculation that updates the risk and impact before saving.
You can still reuse the code that looks for a risk assessment and sets a value for the BR
or alternatively just put the code into the ui action - request for approval and do the query for a risk assessment there?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2018 07:25 PM
Hi Scott,
I have the Calculate Risk ui action with the below codes:
var cra = new ChangeRiskAsmt();
if (cra.hasAssessment(current) && !cra.hasCompletedAssessment(current))
gs.addInfoMessage(gs.getMessage("Complete Risk Assessment to calculate risk"));
else {
var calculatedRisk = cra.calculateRisk(current);
if (calculatedRisk.riskUpdated || calculatedRisk.impactUpdated) {
current.risk = calculatedRisk.risk;
current.impact = calculatedRisk.impact;
current.update();
}
}
action.setRedirectURL(current);
Should I replace the entire code with the one you provided for 'execute risk calculation'?
var scr = new RiskAssessmentCalculator();
var takenRA = '';
var assessmentMatch = scr.checkForMatchingAssessment(current.sys_class_name, current);
if (assessmentMatch == '') {
calcRisk();
}
else {
takenRA = scr.checkForAssessmentInstance(current.sys_id);
//the correct assessment has been taken
if (takenRA != '' && takenRA == assessmentMatch){
calcRisk();
}
if (takenRA != '' && takenRA != assessmentMatch){
gs.addInfoMessage(gs.getMessage('Incorrect risk assessment taken, please fill out a new assessment'));
}
if (takenRA == ''){
gs.addInfoMessage(gs.getMessage('A risk assessment is required, please fill out a risk assessment'));
}
}
function calcRisk() {
var risk = scr.calculateRisk(current);
current.u_risk_assessment_taken = true;
current.update();
}
action.setRedirectURL(current);
I still can't make it work. I have already added the true/false field in the form but it is not working. Is it possible to just edit the 'request approval' ui action so at least upon clicking that, it will give the alert to complete the risk assessment first? The below is the OOTB script for request approval ui action.
function moveToAssess(){
var ga = new GlideAjax("ChangeRequestStateHandlerAjax");
ga.addParam("sysparm_name", "getNextStateValues");
ga.addParam("sysparm_change_sys_id", g_form.getUniqueValue());
ga.addParam("sysparm_change_type", g_form.getValue("type"));
ga.getXMLAnswer(function(stateValues) {
var returnedStates = stateValues.evalJSON();
g_form.setValue("state", returnedStates[0]);
gsftSubmit(null, g_form.getFormElement(), 'state_model_request_assess_approval');
});
}
if (typeof window == 'undefined')
updateAndRedirect();
function updateAndRedirect() {
current.update();
action.setRedirectURL(current);
}