Client Script is not working for non admin users

vinuthna16
Tera Contributor

Hi Team,

The code written below is not working for non admin users.

From

Script include from a custom table getting sys id values of a list field

In Client Script

based on the condition 

if list field in the custom filed - setting one filter

if list field contains sys id's - setting another filter

Here are the codes:

 

function onChange(control, oldValue, newValue, isLoading) {

    if (isLoading || newValue == '') {

        return;

    }

    var idval = g_form.getValue('service catalog field');

    // setting cyber contacts fields

    var gc = new GlideAjax('Populatelistcollectorfileds');

    gc.addParam('sysparm_name', 'scriptincludefunctionname');

    gc.addParam('sysparm_user', idval);

    gc.getXMLAnswer(setfilter);

    var sc = g_list.get('Service catalog list collector field');

    sc.reset();

 

    function setfilter(answer) {

        answer = answer.toString();

        if (answer == 'empty') {      

            sc.setQuery("user_name=''");

        } else {

            sc.setQuery('sys_idIN' + answer);

        }

    }

}

Script Include:

scriptincludefunctionname: function() {
        var id = this.getParameter('sysparm_user');
        var gr = new GlideRecord('');//custom table name
        gr.addQuery('sys_id', id);
        gr.query();
        var check=0;
        if (gr.next()) {
            if(gr.fieldname!=''){
                check=1;
            var val = gr.getValue('fieldname').split(',');
            }
            else{
                check=0;
            }
        }
        if(check==1){
            return val.toString();
        }
        else{
            return 'empty';
        }
    },
Please help me rectify this.
Thanks,
Vinuthna

 

1 ACCEPTED SOLUTION

Harish KM
Kilo Patron
Kilo Patron

Hi @vinuthna16 when you create a client callable script include there is a ACL which gets created. I believe you might have given admin role,  Change it to end user role like snc internal

Regards
Harish

View solution in original post

2 REPLIES 2

Harish KM
Kilo Patron
Kilo Patron

Hi @vinuthna16 when you create a client callable script include there is a ACL which gets created. I believe you might have given admin role,  Change it to end user role like snc internal

Regards
Harish

Maddysunil
Kilo Sage

@vinuthna16 

The issue you're facing might be due to the security restrictions applied to non-admin users. ServiceNow restricts access to certain tables and fields based on user roles and permissions. If the user executing this script doesn't have sufficient privileges to access the specified table, it will result in no records being returned.

Please check the ACL on the custom table.

 

Please Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks