How to prevent a user from changing the problem state before filling out the mandatory fields?

eliana_wise
Tera Contributor

Hi,

Can some one help me to setup a rule that prevents users from changing the state prior to filling out the fields that was set to be visible and be mandatory on another state. In this case I have too fields that I have created a UI policy for them to show up when our problems are at RCA review state, and they are both mandatory, but the problem is that a user can bypass this state and go the the next state; now is there any way to prevent this?

Thanks

5 REPLIES 5

Srinivas Balusu
Kilo Guru

Try using data policies which can handle service side too


SanjivMeher
Kilo Patron
Kilo Patron

Hi Eliana,



You need to write a business rule and check if these fields are filled out. Other wise use current.setAbortAction() to abort the save.



Please mark this response as correct or helpful if it assisted you with your question.

Shishir Srivast
Mega Sage

Hi Eliana,



Please check if this helps. You can have an array of required field and then check if any of the field does not contains any value then set the flag and based upon the flag terminate the form submission.



function onSubmit() {


var reqFields = ['description', 'justification', 'details'];


var check_point = false;


for (var i = 0; i < reqFields.length; i ++) {


var val = g_form.getValue(reqFields[i]);


if(val == '')


check_point = true;


}


if(check_point == true){


alert('Mandatory Fields are required');


return false;


}


}


antin_s
ServiceNow Employee
ServiceNow Employee

Hi Eliana,



Do you want these fields to be Visible when the state is 'RCA Review' and states after that or only when it is 'RCA Review'. I would recommend to the fist option and create a Client Script to check for these fields to be filled for all   'RCA Review' and states after. This will give you a better usability.



Hope this helps. Mark the answer as correct/helpful based on impact.



Thanks


Antin