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.

Update field bypassing other mandatory fields

Rshear
Kilo Expert

Hi all,

here again....

I have a requirement to set a flag (true) on an incident record (however the field is hidden from the form). This sounds simple..although I need to set this flag BEFORE all mandatory fields on the incident form are completed.

Currently I have done this in a ui action however obviously it tells me mandatory fields have not been completed first.

background info:

I have a script include in the ref qualifier of a business service field (amended ci field) which does some funky stuff like only show business services from the same location of the caller entered. However I need to put in an 'override' ability to allow that business service filter to return all. Hence I was thinking If a UI action could set a flag to true..I could add an OR field value = true to the script include to then bring back all.

1 ACCEPTED SOLUTION

Pardeep,



Thanks for pointing in the right direction.


In the interest of sharing.



The solution was:


UI Action:


//onclick function


function overrideBS() {


g_form.checkMandatory = false;


gsftSubmit(null, g_form.getFormElement(), 'overridebs');


}



//as I removed the field off the form then the following also


current.u_override_business_services = 'true';


action.setRedirectURL(current);  


current.update();


View solution in original post

3 REPLIES 3

Slava Savitsky
Giga Sage

How do you hide the field? If you do it with a UI Policy, you should be able to change the value of the field with g_form.setValue() without having to unhide it.


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Russell,



You may find the below thread helpful.


Saving a record without populating all mandatory variables


Pardeep,



Thanks for pointing in the right direction.


In the interest of sharing.



The solution was:


UI Action:


//onclick function


function overrideBS() {


g_form.checkMandatory = false;


gsftSubmit(null, g_form.getFormElement(), 'overridebs');


}



//as I removed the field off the form then the following also


current.u_override_business_services = 'true';


action.setRedirectURL(current);  


current.update();