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.

Skip UI policy of mandatory fields validation

nsfmab
Kilo Contributor

Hi,

Is there any way I can skip the UI policy of mandatory fields validation for certain UI action? The problem I'm facing now is, when the state changes back to draft (UI action: Reset to Draft), the mandatory fields validation should not take place at all. 

find_real_file.png

I was thinking if I can use BR before rule to skip the UI policy for this specific condition ie. state changes to draft, but I have no idea how should I write it in script.

Appreciate your help. Thanks!

2 REPLIES 2

Kieran Anson
Kilo Patron

As a cheat you can name your UI Action "action name" to sysverb_cancel. This allows the saving of the form and ignore mandatory fields.

Chuck covered this in his UI Action video found below

https://youtu.be/_G8X9bi8spE?t=2504

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