On load client is not working for normal user like itil, snc_internal

singhr14
Tera Contributor

need to update the existed form ticket variable earlier it one of the variable type is refrence later it got update to single select as the result the value of the variable change to sys_id. 
So now the task is to convert the sys_id into name. it only working for admin not for the normal user

here are the script 

Client script  :  

var gname = g_form.getValue('generic_mailbox_name');
function onLoad() {
   //Type appropriate comment here, and begin script below
   //var gmvalue  = g_form.getValue("generic_mailbox_name");



   var gr = new GlideAjax('test4');
    gr.addParam('sysparm_name','fieldValues');
    gr.addParam('sysparm_agname',gname);
    gr.getXML(UpdateFields);

    //alert("sys_id is   "+ g_form.getValue('generic_mailbox_name'));
   
   
    function UpdateFields(response){
        var answer = JSON.parse(response.responseXML.documentElement.getAttribute("answer"));
     
        g_form.setValue('generic_mailbox_name',answer.genericmName);

        //alert(answer.genericmName);
   
       
    }
   
}

Script include : test4
var test4 = Class.create();
test4.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    fieldValues: function(){
    var gmName = this.getParameter('sysparm_agname');
    var gr = new GlideRecord('sys_user');


    gr.addQuery('sys_id',gmName);

    gr.addEncodedQuery('sys_id='+ gmName);
   
    gr.query();
    if(gr.next()){
        var json = new JSON();
                var object= {
                    "genericmName": gr.getValue('name')

    };
        var data = json.encode(object);
        return data;
    }
   
},

    type: 'test4'
});




1 ACCEPTED SOLUTION

Chaitanya ILCR
Kilo Patron

Hi @singhr14 ,

The user you are trying fetch the info for is that account inactive?

ChaitanyaILCR_0-1746812744640.png

OOB there is Query BR on the sys_user table which only shows active records for normal users 

 

check below post of mine

https://www.servicenow.com/community/developer-forum/make-locked-user-accounts-available-from-servic...

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

View solution in original post

14 REPLIES 14

@singhr14 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ankur Bawiskar
Tera Patron
Tera Patron

@singhr14 

Is that ajax call happening?

The OOTB ACL which gets created when you create client callable script include, add snc_internal or public role there

Then see with that non-admin user.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar 

I have tried by giving the snc_internal or public role but still its not worrking.

Chaitanya ILCR
Kilo Patron

Hi @singhr14 ,

The user you are trying fetch the info for is that account inactive?

ChaitanyaILCR_0-1746812744640.png

OOB there is Query BR on the sys_user table which only shows active records for normal users 

 

check below post of mine

https://www.servicenow.com/community/developer-forum/make-locked-user-accounts-available-from-servic...

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

@Chaitanya ILCR 

The user  I'm trying is an active user but that user type is Non Person