The CreatorCon Call for Content is officially open! Get started here.

Service Catalog Variable - Inactive users fields not visible

GB14
Kilo Patron

We have modified the OOB business rule "User query" to include the inactive users. The inactive users are visible in the variable but when the end user click the reference icon it just show "record not found", and also the onchange script doesn't work for the non admins to auto fill other reference field based on the users records. 

 

Is there any suggestion what specify needs to be modified to show User ID and the manager field?

 

Thanks
G

1 ACCEPTED SOLUTION

Hello @Divya24 

We created a client script and a script include to achieve this. Hope it helps in your case. 

Script Include: 

var userDataUtil = Class.create();
userDataUtil.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    getUserInfo: function() {
        var user = this.getParameter('sysparm_user');
        var gr = new GlideRecord("sys_user");
        gr.setWorkflow(false);
        gr.get(user);

        var deptname = gr.department.getDisplayValue();
        var managername = gr.manager.getDisplayValue();
        var locationname = gr.location.getDisplayValue();
        var ttl = gr.getValue('title');
        var eml = gr.getValue('email');
        var fName = gr.first_name.getDisplayValue();
        var lName = gr.last_name.getDisplayValue();
        var uName = gr.user_name.getDisplayValue();
        var mNumber = gr.u_mobile_phone.getDisplayValue();

        var response = {};

        response.email = eml;
        response.first_name = fName;
        response.last_name = lName;
        response.user_name = uName;
        response.mobile_phone = mNumber;
        response.department = deptname;
        response.manager = managername;
        response.location = locationname;
        response.title = ttl;
        // response.fullName = name;
       //gs.info(JSON.stringify(response));
        return JSON.stringify(response);
    },
    type: 'userDataUtil'
});

===================================================================

OnChange Catalog Client Script: 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    // Call the GA function
    var ga = new GlideAjax('userDataUtil');
    ga.addParam('sysparm_name', "getUserInfo");
    ga.addParam('sysparm_user', newValue); //Onchange field is reference field to sys_user table
    // alert(newValue);
    ga.getXMLAnswer(function(answer) {
        var response = JSON.parse(answer);
        // alert(response);
        g_form.setValue('first_name', response.first_name); //used for string field
        g_form.setValue('last_name', response.last_name); //used for string field
        g_form.setValue('username', response.user_name); //used for string field
    });
}



 


View solution in original post

6 REPLIES 6

Thanks Rick, I have already modified the business rule "user query". Inactive users are visible now but the OnChange script is not working when impersonating a non admin / end user. 

The OnChange script works fine and the manager field is getting filled without any issues for the admins. 


unable to find any related ACLs 

 

Dr Atul G- LNG
Tera Patron
Tera Patron

HI @GB14 

 

What is business requirement here? Please elaborate

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

@Dr Atul G- LNG 

 

We have a catalog item where we need to fill in the variables based on the selected INACTIVE user. Because only the name is visible the onclient script fails when the end user/nonadmin/itil users are trying to fill the request. 

Everyone can see the disabled user since we have modified the "User query" business rule but auto-fill is not working. The onchange script works fine for active users. Seems like some ACL but I cannot find it. 

 

Divya24
Tera Contributor

Any update on this Im facing the similar issue can someone advise on this please?