Make Risk Assessment on Change Mandatory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2018 05:56 AM
Hi All,
i have recently installed the Change Risk Assessment Plugin. This appears as a related link on the change form. I have set conditions so once taken, it will auto set the Risk for hat change. I wish to make taking the risk assessment mandatory before you can move to the assess phase. I have used the following scripting
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var changeNumber = g_form.getUniqueValue();
var changeType = g_form.getValue('type');
//If state changes from New to Assess check if there is a risk assessment
if((newValue == -4) && (oldValue == -5) && (changeType == 'normal')) {
var gr = new GlideRecord('task_assessment');
gr.addQuery('task', changeNumber);
gr.query();
if(gr.next()){
g_form.addInfoMessage('Risk Assessment has been completed');
return;
}
else{
g_form.addErrorMessage("Risk Assessment needs to be completed before requesting approval. Use the Risk Assessment link under Related Links");
g_form.setValue('state',-5); //Set state to New
return;
}
}
}
This as intended stops the requester from moving to assess phase (when they click the request approval button). It also shows an error message advising they need to take the Risk assessment.
The issue i have, that even when the user has taken the risk assessment, it still does not allow the change to move to the assess phase after requesting approval. It says the same error message - "Risk Assessment needs to be completed before requesting approval. Use the Risk Assessment link under Related Links" even though the usr has taken one.
any ideas how i can get this to work?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2018 06:09 AM
Add return false in your else statement, which will stop from processing.
else{
g_form.addErrorMessage("Risk Assessment needs to be completed before requesting approval. Use the Risk Assessment link under Related Links");
g_form.setValue('state',-5); //Set state to New
return false; // Add false
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2018 06:27 AM
Thanks for the response but still does not work. My issue is that it'snot processing to the next phase after a risk assessment has been taken.
when the end user hits request approval, it should go to the next phase (from new to assess). The idea is that if the end user hasn't done a risk assessment for this change, it will not let them go to the next phase. If they have done one it will. Issue is that even when the end user has completed a risk assessment, it is still not letting them go to the next phase.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2018 09:01 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2018 09:24 AM
That sounds better logic,
how would the scripting look for the business rule? I'm struggling with that bit