Risk Assessment

Mira1992
Kilo Sage

Hello community,

We are encountering an issue with the Risk Assessment table (sn_risk_assessment_instance). When an assessor attempts to submit a risk assessment using the "Respond" UI action, an error message appears: "Please fill all mandatory fields."

Same message appears when I try to go Back to control assessmentor when I try to reassign

 

Mira1992_0-1725532278343.png

 

I have checked the UI Policies and Client Scripts but didn't find anything relevant. I've also added every field to the form to see if any would be marked as mandatory, but nothing showed up. I even changed the form view, but the issue persists.

Has anyone experienced a similar issue? How can I identify the missing or empty mandatory field causing this error?

For reference, the error message "Please fill all mandatory fields" seems to originate from the Client Script titled "Save Assessments."

Here's the code:

function onSubmit() {

    if (gel(g_form.getActionName()) == null) return;

    if (g_scratchpad.submit) {

        g_scratchpad.submit = false;

        return true;

    }

    var ajax = new GlideAjax('sn_risk_advanced.RiskAssessmentAJAX');

    ajax.addParam('sysparm_name', 'saveMitigationCtrlAndResidualRiskFlags');

    ajax.addParam('sysparm_asmtId', g_form.getUniqueValue());

    ajax.addParam('sysparm_state', g_scratchpad.state);

    ajax.addParam('sysparm_isMitigationCtrlsFlagSet', g_form.getValue('mitigating_controls_to_assess'));

    ajax.addParam('sysparm_isResidualRiskFlagSet', g_form.getValue('residual_risk_not_applicable'));

    ajax.getXMLAnswer(function(answer) {

        var state = g_scratchpad.state;

        if (canSaveAssessment(state)) {

            var assessmentKey = getAssessmentKey(state);

            var assessmentData = g_scratchpad[assessmentKey];

            if (((state == '3' && g_form.getValue('mitigating_controls_to_assess') == 'false') || (state == '4' && g_form.getValue('residual_risk_not_applicable') == 'false') || (state == '2')) && (assessmentData.canSave || (assessmentData.valid && g_form.getActionName() == 'reassign_assignee'))) {

                if (assessmentData.requestPayload && Object.keys(assessmentData.requestPayload).length != 0) {

                    //Until assesment responses are saved an animated progress bar will be shown

                    var modal = new GlideModal('sn_risk_advanced_progress_animated_bar', true);

                    modal.setBackdropStatic(true);

                    modal.setSize(100, 100);

                    modal.render();

                    var ajax = new GlideAjax('sn_risk_advanced.AdvancedRiskAssessmentScoringAJAX');

                    ajax.addParam('sysparm_name', 'commitResponses');

                    ajax.addParam('sysparm_responses', JSON.stringify(assessmentData.requestPayload));

                    ajax.getXMLAnswer(function(answer) {

                        //Once responses are saved dismiss progress bar

                        /*This timer is required because if response if very fast UI page will be like flicker.

                          So waiting for one second after responses are saved.*/

                        setTimeout(function() {

                            g_scratchpad.submit = true;

                            return gsftSubmit(gel(g_form.getActionName()));

                        }, 1000);

                    });

                } else {

                    g_scratchpad.submit = true;

                    return gsftSubmit(gel(g_form.getActionName()));

                }

            } else {

                if ((state == '3' && g_form.getValue('mitigating_controls_to_assess') == 'true') || (state == '4' && g_form.getValue('residual_risk_not_applicable') == 'true')) {

                    g_scratchpad.submit = true;

                    return gsftSubmit(gel(g_form.getActionName()));

                }

                //This class adds border color as red for all mandatory fields in an assessment

                if (!assessmentData.valid && !assessmentData.allMandatoryFilled) {

                    g_form.addErrorMessage(getMessage("Please fill all mandatory fields and also provide valid responses"));

                } else if (!assessmentData.valid) {

                    g_form.addErrorMessage(getMessage("Please provide valid responses"));

                } else {

                    g_form.addErrorMessage(getMessage("Please fill all mandatory fields"));

                }

                document.querySelector("#" + assessmentKey + " #assessment_form").addClassName('submitted');

            }

            return false;

        } else {

            g_scratchpad.submit = true;

            return gsftSubmit(gel(g_form.getActionName()));

        }

    });

 

    function canSaveAssessment(state) {

        return state == '2' || state == '3' || state == '4';

    }

 

    function getAssessmentKey(state) {

        if (state == '2') {

            return "inherent_assessment";

        } else if (state == '3') {

            return "control_assessment";

        } else if (state == '4') {

            return "residual_assessment";

        }

    }

    return false;

}




1 ACCEPTED SOLUTION

Mira1992
Kilo Sage

Great news, we found the solution!

The field "residual_risk_not_applicable" needs to be present on the form. Once I added this field back to the Risk Assessment form, under the Residual Assessment section, I was able to proceed with the assessment to the next state.



Mira1992_0-1725549828612.png

 

View solution in original post

3 REPLIES 3

Community Alums
Not applicable

Hi @Mira1992 ,

You will need to make sure all the below highlighted tabs  has few mandatory fields, which needs to be filled , then the Respond button will work:

SandeepDutta_1-1725542782071.png

 

 

 

Hello Sandeep,
all the visible mandatory fields are of course populated of course. That was not what I was asking for.
My question was ... how do I find if there are some hidden mandatory fields?

My quest is that there is some dot walked field somewhere which needs to be populated but still not sure.

Mira1992
Kilo Sage

Great news, we found the solution!

The field "residual_risk_not_applicable" needs to be present on the form. Once I added this field back to the Risk Assessment form, under the Residual Assessment section, I was able to proceed with the assessment to the next state.



Mira1992_0-1725549828612.png