- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2020 04:28 PM
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:
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
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2020 10:01 PM
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
}
Hope this helps.
Mark helpful or correct based on impact.
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2020 06:17 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2020 09:30 PM
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".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2021 05:27 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2021 08:50 AM
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.
Also, our BR is a little different than posted here, so feel free to try this version which I have in my PDI.
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