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.

How can we disable the error Invalid value on Update?

e_wilber
Tera Guru

For whatever reason, we're getting the following error after clicking a UI action even though the UI action is successful in setting all of the field values correctly. Since there really isn't an error, is there a line of code I can add to this to clear this type of alert message for this UI action?

find_real_file.png

7 REPLIES 7

Willem
Giga Sage
Giga Sage

Hi,

I would try and find out where the error message is coming from and address the issue.

In my opinion hiding/suppressing the error is not a good idea.

The issue is pretty simple. SN doesn't like the bold line below. I can update literally any other field on the form and it's fine but when I update the class name it sends me an error (even though it actually changes the sys_class_name properly.

Side note: This class move is kosher. We have multiple extensions from the sn_customerservice_case table and every custom field is added to the base table directly so we can transfer cases from one type to another without any data loss.

(function executeRule(current, previous /*null when async*/) {

var cs = new GlideRecord('sn_customerservice_case_gcc');
cs.addQuery('sys_id', current.sys_id);
cs.query();

if (cs.next()) {
gs.log('Converting the new case to: ' + current.u_convert_case_to);
cs.sys_class_name = current.u_convert_case_to;
cs.update();

}

})(current, previous);

Ah oké, have you tried cs.setWorkflow(false); before the cs.update() line?

Reference: https://developer.servicenow.com/dev.do#!/reference/api/quebec/server/r_ScopedGlideRecordSetWorkflow...

Other option would be like HR does it, there, on transferring a Case they instead create a copy and set the old Case to Inactive. You then always have the old record for reference and do not have to change sys_class_name.

You can either transfer the number to the new Case record and the new generated Case number to the old (so switch numbers). Or give the new Case a new number and inform the user