Can We bypass the mandatory field in a form

sam352120
Kilo Guru

Hi ,

 

Can we submit a form by not filling the mandatory field .Is that possible through any script or any method.

Please share your ideas.

7 REPLIES 7

servicenow_live
Tera Contributor

https://community.servicenow.com/community?id=community_article&sys_id=d05b9dd0dba67c10457ae6be139619ee

pawan k singh
Tera Guru

You can Try using below code in UI Action. It will work...


function callClientScript() {
//Client Script
var arr = g_form.getMissingFields();
for (var x = 0; x < arr.length; x++) {
g_form.setMandatory(arr[x], false);
alert("Following mandatory fields are not filled : " + arr[x]);
}

gsftSubmit(null, g_form.getFormElement(), 'update_to_p1');
}

if (typeof window == 'undefined')
callServerScript();

function serverScript() {
// Server Script
current.update();
action.setRedirectURL(current);
}

 

pawan k singh
Tera Guru

You can try below code on UI action. It will work.

function callClientScript() {
    //Client Script
    var arr = g_form.getMissingFields();
    for (var x = 0; x < arr.length; x++) {
        g_form.setMandatory(arr[x], false);
        alert("Following fields are set Non Mandatory: " + arr[x]);
    }
    gsftSubmit(null, g_form.getFormElement(), 'update_to_p1'); // UI action name
}

if (typeof window == 'undefined')
    callServerScript();

function serverScript() {
    // Server Script
    current.update();
    action.setRedirectURL(current);
}

find_real_file.png

Please mark answer helpful if it helped.
Regards
Pawan K Singh