Receiving this error "Javascript Error in Browser Code" in the Portal for one of the catalog item

Appu2
Tera Contributor

Hi, I am receiving this error "Javascript Error in Browser Code" in the Portal for one of the catalog item for those who don't have any roles. I am the admin or anyother with itil role does not see this error but the ones without any roles get stuck with this error on the browser.

I have created an onload Client Script for the catalog item.

Below is the code:-

function onLoad() {
 
    var ga = new GlideAjax('KPMG_nTAAPDetails');
    ga.addParam('sysparm_name', 'retrieveDetails');
    ga.getXMLAnswer(setProjectDetails);
 
    function setProjectDetails(response) {
 
        var result = JSON.parse(response);
      //  console.log(result);
        var getaccessType = result.initialValuesArray;
for (var accessTypes = 0; accessTypes < getaccessType.length; accessTypes++) {
            g_form.addOption('access_type', getaccessType[accessTypes], getaccessType[accessTypes]);
        }
var values = result.uniqueValuesMap;
 
var valueProjName = values["Business User"].u_project_name;
for (var valueIndex = 0; valueIndex < valueProjName.length; valueIndex++) {
g_form.addOption('application_name', values["Business User"].u_project_code[valueIndex], valueProjName[valueIndex]);
}
 
var valueEnvironmentName = values["Business User"].u_environment_team_name;
for (var buEnvironmentIndex = 0; buEnvironmentIndex < valueEnvironmentName.length; buEnvironmentIndex++) {
g_form.addOption('environment', values["Business User"].u_environment_teams_code[buEnvironmentIndex], valueEnvironmentName[buEnvironmentIndex]);
}
 
var pdValueProjName = values["Product Development"].u_project_name;
for (var pdValueIndex = 0; pdValueIndex < pdValueProjName.length; pdValueIndex++) {
g_form.addOption('department_teams_area', values["Product Development"].u_project_code[pdValueIndex], pdValueProjName[pdValueIndex]);
}
 
var pdValueEnvironmentName = values["Product Development"].u_environment_team_name;
for (var pdEnvironmentIndex = 0; pdEnvironmentIndex < pdValueEnvironmentName.length; pdEnvironmentIndex++) {
g_form.addOption('safe_teams', values["Product Development"].u_environment_teams_code[pdEnvironmentIndex], pdValueEnvironmentName[pdEnvironmentIndex]);
}
 
    }
}
 
I need some inputs that why for people with no roles this error is happening.
Any insights would be helpful!
 
9 REPLIES 9

Brad Bowman
Kilo Patron
Kilo Patron

What does the error say in the browser console?  I have seen this message when the Script Include does not return anything - so maybe the unrolled users are encountering trouble calling the SI, or something in that script?  Make sure the SI is coded to always return something then add logs to see if it is getting called, and how far it is getting for these users.

Appu2
Tera Contributor

In the console it says: Unhandled Exception in GlideAJAX.

Yes the script include I created does return a value and I have tested it in Background script as well. It's working

Just to clarify, does the SI return a value for one of these users when getting the error?

No like in the script include I have the choices for the fields in catalog item but they are not able to see those values in the portal form.