Getting an error "submit canceled due to a script error - please contact your system administrator"

Nagurbee1
Tera Contributor

Hi All

Non admin users are getting an error "submit canceled due to a script error - please contact your system administrator"  while clicking on save/update after filling the variables(present on multirow variable set) under Details & Variables section on catalog task(sc_task).

I have written the below onSubmit script in order to restrict the duplicate entries on a Multi Row Variable set.

 

function onSubmit() {

var value = parent.g_form.getValue("name of the MRVS");
var arr = JSON.parse(value);
var totalLength = arr.length;

var arr2 = [];
for (var i = 0; i < arr.length; i++) {
if (!searchExisting(arr[i].variable_name_to_be_unique, arr2)) {
arr2.push(arr[i]);
}
}

var finalObjLength = arr2.length;

if (finalObjLength != totalLength) {
alert('There are duplicates in host names please remove those before submitting');
return false;
}
}

function searchExisting(variable_name_to_be_unique, newArray) {

for (var i = 0; i < newArray.length; i++) {
if (newArray[i].variable_name_to_be_unique == variable_name_to_be_unique) {
return true;
}
}
return false;

}

 

So my question is , why non admin users are getting that error and is my script causing that error ?

Could you please provide me solution that how can we resolve this issue ?

 

Thanks in advance

Nagurbi

6 REPLIES 6

Saurav11
Kilo Patron
Kilo Patron

Hello,

 

Please check the below support article for the same:-

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0720671

 

Please mark my answer as correct based on Impact.

Hello Saurav

Thanks for the quick response and I have a question as mentioned below.

1.We can't give the role "client_script_admin" to all non admin users right, so is there any other way to overcome this error ?

2.They are not getting this error when they are updating the catalog tasks without entering the MRVS entries and they aren't getting this error when they are updating other catalog tasks(submitted for other catalog items), so is my scripting causing an error ?

 

Thanks in advance

Nagurbi

It can be due to the script. are your mvrs fields showing on the RITM form?

No, fields are visible only on catalog task.

And also we are getting the another error message "onSubmit script error: TypeError....."(please refer the attached screenshot) , even admin users are getting this error when they try for the first time to update and not getting error when they are trying from second time.

 

Thanks in advance

Nagurbi