How to clear all the variables/fields values
Import
·
Feb 21, 2022
·
article
This is applicable for client side scripting (both Catalog and table level)
Make them readonly, mandatory or clear all variable/field values when the respective field changes.
var fieldArr = ['Field_A', 'Field_B', 'Field_C', 'Field_D', 'Field_E', 'Field_F'];
//add comma separated field names which you want to clear here
for (var i = 0; i < fieldArr.length; i++) {
g_form.clearValue(fieldArr[i]);
}
//Similarly we can use other methods like - g_form.setReadOnly, g_form.setMandatory or g_form.setDisplay
for (var i = 0; i < fieldArr.length; i++) {
g_form.setReadOnly(fieldArr[i], true);
if (g_form.getValue(fieldArr[i]) == "") {
g_form.setDisplay(fieldArr[i], false);
}
}
Thanks to @Mike Patel
View original source
https://www.servicenow.com/community/now-platform-articles/how-to-clear-all-the-variables-fields-values/ta-p/2307008