Make mandatory fields non-mandatory

karthikbabu
Giga Expert

Hi friends,

While cancelling a change through UI Action the mandatory fields should be become non-mandatory. Below is my UI action "Cancel Change"  code.

"new Workflow().cancel(current);
current.state=10;
current.u_rejected_change=true;
current.update();
var wf = new Workflow();
wf.cancel(current);

var curTasks = new GlideRecord('change_task');
curTasks.addQuery('change_request', current.sys_id);
curTasks.query();
while(curTasks.next()){
curTasks.state = 4;
curTasks.update();
}

action.setRedirectURL(current);"

 

Please suggest.

Thank You,

Karthik

 

1 ACCEPTED SOLUTION

You would place this in the client script portion of your UI action.

So if you follow that link and see how to make your UI action both server side and client side capable...your client side would just be that code I put above.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

5 REPLIES 5

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