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

Hello @ChuanYanF 

 

Again, the field types matter. Are the field types same ? Especially for drop-down fields like this. 

 

Can you show these fields once. 

 

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.

This is the two fields both are string.

ChuanYanF_0-1742542574091.png

ChuanYanF_1-1742542620765.png

 

 

Hello @ChuanYanF 

 

Also, I am not understanding this .assessment instance that you are doing. Can you show this as well. ? 

 

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

The assessment instance is because the risk rating scoring that I want to get the data from is from this risk assessment instance table that is performed for the risk. Then will generate a risk response task based on the risk respond after the risk assessment has been done. 

ChuanYanF_0-1742542845917.png

 

Hello @ChuanYanF 

 

That I have understood from your previous screenshots. But I want to understand is Risk assessment a field in the "RISK" Field which you dot walked from "RESPONSE". 

 

If it is a field only then you can dot walk again. If it's a related list you need to glide on it. 

 

My precise question is - how are you identifying the exact assessment of a response task ? There must be some field that is common. 

 

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