Array is returning null

tsoct
Tera Guru

The script include will return the stringify value shown below.

*** Script: JSON.stringify(obj): ["ABC","AF","EFD","CGED","AAAA","BBBB","CCCC","ZZZZZ",""]

 

I want  value above to appear in a Select Box type of catalog variable. The catalog client script below returns null as an answer. What could have gone wrong?

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }

    var gb = new GlideAjax('ORGANIZATIONAjazUtils');
    gb.addParam('sysparm_name', 'getName');
    gb.getXML(getResponse);

    function getResponse(response) {
        var answer = response.responseXML.documentElement.getAttribute("answer");
        alert("Answer: " + answer); //null is returned
        var array = answer.split(',');
        for (var i = 0; i < array.length; i++) {
            g_form.addOption('client_company_name', array[i].toString(), array[i].toString());
        }
    }

}

 

1 ACCEPTED SOLUTION

KevinBellardine
Kilo Sage

Hey @tsoct 

 

I've gone through this in my own PDI, and the only way I was able to replicate what you're seeing was if the user triggering the change didn't have the role for the script include. Have you checked the SI ACL?

View solution in original post

11 REPLIES 11

KevinBellardine
Kilo Sage

Hey @tsoct 

 

I've gone through this in my own PDI, and the only way I was able to replicate what you're seeing was if the user triggering the change didn't have the role for the script include. Have you checked the SI ACL?

This is indeed the reason!