Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Mandatory fields not working while saving

pramn
Kilo Sage

Hi Team , 

 

What could be the reason one of form is not validating mandatory fields while saving .

How can i fix this ? Looking forward your help in this .

pramn_0-1670115701893.png

 

3 REPLIES 3

Mike_R
Kilo Patron
Kilo Patron

"Save" looks like a custom UI action. It's possible that it's configured to ignore the mandatory fields. Can you post the code for the UI action?

//&& new NCNTS_Utils().remediationPlanApprovalCheck(current)
function SaveRemeRecord(){

ignoreMandatoryCheck();
gsftSubmit(null, g_form.getFormElement(), 'save_reme_record');

}
if (typeof window == 'undefined')
Save_record();
function ignoreMandatoryCheck(){
var i;
var arrValues = g_form.getMissingFields().toString().split(',');
for (i=0;i<arrValues.length;i++){
g_form.setMandatory(arrValues[i],false);
}
}

function Save_record(){

if (current.u_verification_task_required == 'Yes' && current.state == 10 && current.u_associated_verification_task == ''){

var gr = new GlideRecord("u_verification_task");
gr.initialize();
gr.parent = current.parent;
gr.u_remediation_task_number = current.sys_id;
gr.assigned_to = current.parent.u_remediation_plan_owner;
var verID = gr.insert();
current.u_associated_verification_task = gr.sys_id;
action.setRedirectURL(gr);
gs.addInfoMessage('New Verification Action Created.');
}else{

action.setRedirectURL(current);
}
//current.state = -5;
current.update();
}