How to disable mandatory fields

kmathis
Kilo Contributor

I have configured mandatory fields for our Change form through UI Policy.   I now need to configure a UI Action to cancel the change.   Upon choosing this Cancel menu option, we are currently prompted regarding the mandatory field requirements.   How can I disable the mandatory fields through this UI Action.   Below is my feeble attempt which is currently not working (I only added one field for testing):

function cancel (){

      if(g.form.getValue('short_description')=="")

              g_form.setMandatory('short_description, false');

}

//Canceled state  

var recordState = current.state.getDisplayValue();  

current.state = 4;

// update all the waiting approval to not longer required  

var gr = new GlideRecord('sysapproval_approver');  

gr.addQuery('sysapproval', current.sys_id);  

gr.query();      

if(gr.next()){  

do {  

      if(gr.state == 'requested') {  

          gr.state = 'Canceled';  

          gr.comments = 'The change has been canceled. Your approval is no longer required.'  

          gr.update();  

      }  

gs.eventQueue("change.approver.canceled", gr, gr.approver.getName(), gs.getUserName());  

} while (gr.next())  

}  

current.approval = 'Canceled';

     

moveToCancel();

      function moveToCancel(){

              current.update();

      action.setRedirectURL(current);

                      current.moveTo("Canceled")

}

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

Hi Kari,



Create a UI action with the "action name" field set to sysverb_cancel.



It will then ignore the mandatory fields and do what you need.



For what it's worth, place this in the form context menu so people don't accidentally click it instead of Update or some other button.



UI Actions - ServiceNow Wiki


View solution in original post

5 REPLIES 5

kshaw
Giga Guru

Hoping for some new help on this issue.

Want to limit the "Update" button to ignore mandatories only for a specific Service Catalog. This would be applicable for both RITMs (sc_req_item) and TASK (sc_task) of those items. Don't want to change the rest of the requests used by ITS in the instance.