How do I add a field that will auto populate the inherent risk rating result in risk response task?

ChuanYanF
Tera Guru

Dear experts,

 

I would like to add a field which is the inherent risk rating result after the users have completed the risk assessment and the score will be reflected when they create a risk response task in the risk response form. I tried to create a new business rule which is as below. But it does not work, any suggestions to approach this matter?

 

(function executeRule(current, previous /*null when async*/) {
    if (!current.risk_assessment) {
        return;
    }

    var riskAssessment = new GlideRecord('sn_risk_advanced_risk_assessment_instance');
    if (riskAssessment.get(current.risk_assessment)) {
        current.inherent_risk_rating = riskAssessment.summary_inherent_risk_score;
    }
})(current, previous);
1 ACCEPTED SOLUTION

Hi, so I tried and this is the script that is working for now

(function executeRule(current, previous /*null when async*/) {

    if (!current.risk) {
        gs.info("dont have assosciated risk ")
        return; // Skip if there's no linked Risk or if Inherent Risk is already set
    }

    var risk = new GlideRecord('sn_risk_risk');
    if (risk.get(current.risk)) {  
        gs.info(current.risk);
        var assessment = new GlideRecord('sn_risk_advanced_risk_assessment_instance');
        assessment.addQuery('risk', risk.sys_id);
        assessment.orderByDesc('sys_created_on'); // Get the latest assessment
        assessment.query();

        if (assessment.next() && assessment.summary_inherent_risk_score) {  
            current.u_inherent_risk_rating = assessment.summary_inherent_risk_score;
            gs.info('Inherent Risk Score set to ' + assessment.summary_inherent_risk_score + ' for Risk Response Task: ' + current.sys_id);
        }
    }
})(current, previous);

View solution in original post

26 REPLIES 26

Shivalika
Mega Sage

Hello @ChuanYanF 

 

What are the trigger conditions of your rule ?

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwN

eEISQCY.

 

So in a risk assessment lifecycle trail right, a user will conduct the risk assessment with inherent assessment, control assessment and residual assessment. Then the user will need to respond, there are 4 responses now which are accept, mitigate, transfer and avoid. So when a user selects any response task, and click create response task, the specific response task for each response will be generated like example, if accept and mitigate is selected then when create a risk response task, a risk acceptance task and a risk mitigation task will be created. Then my requirement is to include the inherent risk rating result field in the form of the response task that is generated based on the response.

Hello @ChuanYanF 

 

 

Ok. So you created this on insert business rule in response task table right ? 

 

Then there should be a risk assement related field in there via which you can dot walk and set the value in the response task form. 

 

Can you share the screenshot of the response task form ? 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY.

 

I checked in the risk response task table, the dictionary entry there does not have a risk assessment field that can dot walk. I am sharing two screenshots for u, one is how the risk response and the risk assessment is related and the second one is how the risk response task is populated in the form view. So as you can see there is a risk field there that is populated based on the risk assessment that is assessed on the risk. I want the inherent risk rating for the risk assessment that has just been performed to populate here in the risk response form as well which is in the last screenshot.

ChuanYanF_0-1742538843450.pngChuanYanF_1-1742538857296.png

ChuanYanF_2-1742538945342.png