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

Catalog item: How to get value of one variable based on another variable

vidhya_mouli
Giga Sage

I have catalog item with 2 variables employee and group. Employee is a reference field based on sys_user table. Group is also a reference field based on sys_user_group table. When I choose the value of the employee, i want to display only those group to which this employee belongs. How to do this?

1 ACCEPTED SOLUTION

swathisarang98
Giga Sage

Hi @vidhya_mouli ,

 

You can achieve this by creating script include and calling it through reference qualifier,

 

You can add reference qualifier in Group field like below,

swathisarang98_0-1709289672970.png

 

 

 

javascript: new getuserGroup().getgroupDeatils(current.variables.user)

 

 

 

Script Include:

swathisarang98_0-1709290298002.png

 

 

 

var getuserGroup = Class.create();
getuserGroup.prototype = {
    initialize: function() {
    },

	getgroupDeatils: function(user){
		var sysId = user;
		var groupName = new GlideRecord('sys_user_grmember');
		groupName.addQuery('user',sysId);
		groupName.query();
		var arr =[];
		while(groupName.next()){
			arr.push(groupName.group.toString());
		}
		gs.info('line number 15 ' + arr);
		// gs.info('line number 16 ' + arr.toString());
		// gs.info('line number 17 ' + arr.getDisplayValue());
			return 'sys_idIN'+ arr;
	},

    type: 'getuserGroup'
};

 

 

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

View solution in original post

16 REPLIES 16

Hi @vidhya_mouli ,

 

What is the error you are getting ?

 

Thanks 

Swathi

 

@vidhya_mouli , check whether Abel tuter profile has any Group attached to it if not try adding few and then do your testing ...then Group will give you only the names list which Abel tuter has.

 

If group is not there then it will show something like below,

swathisarang98_0-1709298100522.png

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

He had two groups attached.

@vidhya_mouli can you please give me screenshots of log which you are getting ?

and please share the script include screen shot aswell.

 

Thanks 

swathi 

What I noticed was, my script include is not getting called.

javascript: new getuserGroup().getgroupDeatils(current.variables.employee_name)

 

vidhya_mouli_0-1709301883870.png