We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Mandatory Risk Assessment to advance Change Request

JP-ODU
Tera Guru

My users say they would like the fields on the related list Risk Assessment for their Change requests to just appear on the Change request form, vs clicking open from the Risk Assessment related list (screenshot)

 

change req risk asmt related link.jpg

 

I can't seem to figure out a way to do this? Is it even possible?

1 ACCEPTED SOLUTION

JP-ODU
Tera Guru

When I went back to the team to ask *why* this is necessary, they explained that they want to make the risk assessment mandatory to advance the change request state. So their logic is transfer the mandatory risk assessment fields onto the change_request form and then they'll be mandatory to advance the request.

 

The correct way to address this is a business rule on the change_request table that triggers before state changes and checks that the related assessment instance is complete. Script for that: 

 

(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); 
	gs.addInfoMessage('Please complete the risk assessment related link before proceeding.'); 
	current.state = 1; //check state value 

}  

})(current, previous);

View solution in original post

7 REPLIES 7

But also, I'm willing to accept that "a custom ui upgrade requiring continuous maintenance" counts as a solution of "no don't do this" 😉

It's a tough choice for some... but an easy one seen from my side 😉 
But the UI formatter could be the "answer" if it's not NO 😛 



 If this pointed you in the right direction, hit Helpful to spread the good vibes.
If it cracked the case for you, mark it Correct so the next person doesn’t have to reinvent the wheel.

JP-ODU
Tera Guru

When I went back to the team to ask *why* this is necessary, they explained that they want to make the risk assessment mandatory to advance the change request state. So their logic is transfer the mandatory risk assessment fields onto the change_request form and then they'll be mandatory to advance the request.

 

The correct way to address this is a business rule on the change_request table that triggers before state changes and checks that the related assessment instance is complete. Script for that: 

 

(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); 
	gs.addInfoMessage('Please complete the risk assessment related link before proceeding.'); 
	current.state = 1; //check state value 

}  

})(current, previous);