How to make Risk Assessment Mandatory on Change Request, before submitting for approval

Baggies
Kilo Guru

I am trying to force users to complete a risk assessment on Change Request, before it can go for Approval.

I would like to use the functionality from the 'Calculate Risk' UI Action, which checks for a completed Risk Assessment. If one hasn't been done, the Info Message 'Complete Risk Assessment to calculate risk'  is displayed. This UI Action has the condition "&& new ChangeRiskAsmt().showRiskCalculation(current)" which I thought I may be able to leverage.

I have read a few suggestions about adding script to the UI Action, but I have failed miserably. Here is one for example:

https://community.servicenow.com/community?id=community_question&sys_id=3444cb29dbd8dbc01dcaf3231f96....

has anyone found a way to force a risk assessment to be done before it going for Approval? I really don't want to do it on a client script either.

Many thanks,

Mark S

 

 

 

1 ACCEPTED SOLUTION

Narendra Kota
Mega Sage

You can write a business rule.

Table: change_request

when to run: before update

condition: state changes to // give state value here, like awaiting approval etc.

var assessmentinstance = new GlideRecord ('asmt_assessment_instance'); 
assessmentinstance.addQuery('task_id', current.sys_id);
assessmentinstance.query();
if(!assessmentinstance.next())
	{
	current.setAbortAction(true);
	gs.addInfoMessage('Please perform risk assesment before requesting for approval');
	current.state = 1; //check state value
	current.approval = 'not requested'; //remove it if you don't want to set approval
		
}

find_real_file.png

 

Hope this helps.
Mark helpful or correct based on impact.

Thanks.

View solution in original post

8 REPLIES 8

Michael Fry1
Kilo Patron

Assuming you're referring to the latest Risk Assessment plugin, you can write a simple business rule like below. Risk (field) is really the trigger since it's the Risk Assessment that sets that field:

 

find_real_file.png

 

find_real_file.png

Baggies
Kilo Guru

Thanks for the reply, I had tried this. But the trouble is, once you click on "Request Approval", the state changes to "Assess", and stays there. So a user could clear the error message, hit "Request Approval" again, and the Change will move on, as the state is not being reset to "New". 

 

Hi Baggies, I too am having the same issue, I created an CR yesterday and kept it at new state but my change manager moved it to access state, and now I cannot reset the work flow as its showing a risk assement not calculated. Could you please help me out with your experience on this issue.

Hello, first of all do you have the Revert To New option available which will reset the Change back to New. It's on the hamburger drop down.

For our instance, we skip the Assess stage as we don't require technical approval, we're happy with Manager, Business, and CAB Approval. Just our preference.

find_real_file.png

Also, our BR is a little different than posted here, so feel free to try this version which I have in my PDI.

find_real_file.png

Condition you may have to play with as we dont use Assess stage:
(current.state.changesTo(-3) && current.type=='normal') || (current.state.changesTo(-4) && current.type=='normal') || (current.state.changesTo(-3) && current.type=='emergency')

 

(function executeRule(current, previous /*null when async*/ ) {
    var assessmentinstance = new GlideRecord('asmt_assessment_instance');
    assessmentinstance.addQuery('task_id', current.sys_id);
    assessmentinstance.query();
    if (!assessmentinstance.next()) {

        // current.setAbortAction(true);

        var message1 = '* Please perform Risk Assesment before requesting approval *';
        var message2 = message1.fontcolor("red");
        gs.addInfoMessage(message2);
        //gs.addInfoMessage('Please perform risk assesment before requesting approval');
        current.state = -5; //check state value THIS IS 'NEW' STATE
        current.approval = 'not requested'; //remove it if you don't want to set approval
    }
})(current, previous);

Hope this helps