Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

show the groups only where the requested by is a part of

suprajam
Tera Contributor

Hey, i have a reference field which i have to populate with the groups for which the "requested by" is a part of "only". Help please.

12 REPLIES 12

Demo:-

Reference Qualifier :-

GunjanKiratkar_0-1669229023819.png

 

Script Include :-

GunjanKiratkar_1-1669229044268.png

 


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

hey one last doubt how will it proide the requested bys groups only here like where is it referred

 

Oh i'm sorry,

Make changes as below: if you are using it in catalog then use "current.variables.requestedForVariableName", if not for catalog then "current.requestedForFieldName"

 

GunjanKiratkar_0-1669230014453.png

 

Script Include :-

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

    getGroups: function(getReq) {
        var groupArr = [];
        var uID = getReq;
        var grmember = new GlideRecord('sys_user_grmember');
        grmember.addQuery('user', uID);
        grmember.addQuery('group.active', true);
        grmember.query();
        while (grmember.next()) {
            groupArr.push(grmember.group.toString());
        }
        return 'sys_idIN' + ret;
    },
    type: 'getAjax'
});

 


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

Thanks tons'

 

hey i am trying it is not working though i am checking it.