Clearing mandatory fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2014 01:27 AM
Hi,
We have various hidden fields that become active and mandatory on certain status changes (resolved, assigned to 3rd party etc) if someone has selected the status by mistake when they switch to the correct status the fields stay mandatory and the user has to come out of the ticket without saving and go back in. Any ideas on how to resolve this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2014 02:35 AM
HI Steve
I have changed the incident state to resolved then "closure codes" and "closure notes" were mandatory and then I changed the state to assigned and the mandatory fields were disappeared.
I am not able to replicate the issue on demo instance.
For instance you can check on demo instance.
https://demo002.service-now.com/login.do
Note: My gutt feeling is that there might be some other client script on the same field which may be the culprit in your instance.
Also regarding the script you pasted above I don't see any issue with it. As a best practice I would recommend that you should go with the "UI policy" something like this.
Please let me know if you have any questions
Thanks
Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2014 02:44 AM
Hi,
So your demo has helped to pin point the issue. If I resolve the incident
using the drop down and then use the drop down to change the status the
mandatory fields clear. the issue is using the button on the top of the
form, if you select that and then change the satus using the status drop
down the mandatory fields remain. I have included the script and a
screesnhot of the UI Action behind the button.
function resolveIncident(){
//Set the 'Incident state' and 'State' values to 'Resolved', and display
mandatory fields
g_form.setValue('incident_state', 6);
g_form.setValue('state', 6);
//if (g_form.getValue('comments') == '') {
//Remove any existing field message, set comments not mandatory, and
show a new field message
// try {g_form.hideFieldMsg('comments');} catch(e) {}
//g_form.setMandatory('comments', false);
//g_form.showFieldMsg('comments','Comments are required when
resolving an Incident','error');
//return false; //Abort submission
// }
//Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(), 'resolve_incident'); //MUST
call the 'Action name' set in this UI Action
//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if (typeof window == 'undefined')
serverResolve();
}
function serverResolve(){
current.incident_state = 6;
current.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2014 02:56 AM
Hi Steve,
I think as a workaround we have to change the state value manually from the dropdown to reset the changes.
Looking for others inputs as well
Thanks
Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2014 03:03 AM
Hi, thats what dosnt work. so my workflows for both methods of resolving
accidently are as follows
Use the drop down to select resolved --> fields show and are mandatory ->
use drop down to change from resolved -->mandatory fields reset and are
hidden again
Use the resolve button to resolve --> fields show are are mandatory --> use
drop down to change from resolved--> mandatory fields remain
Regards

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2014 03:12 AM