We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Restricting values in record producer reference fields

umaaggarwal
Giga Guru

I have 3 fields in a record producer , user , role and group. all are reference fields . I want user to be selected as logged in user, groups which are available should be only user's group and roles which should be available are selected groups role

1 ACCEPTED SOLUTION

Hi Uma,

You can call like this

javascript:new FillGroup ().getGroupRoles(current.variables.your_group_var)

View solution in original post

10 REPLIES 10

Hi Asif,

 

I tried it and wrote below 

 

var FillGroup = Class.create();
FillGroup.prototype = {
initialize: function() {
},
find_group:function()
{
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user',gs.getUserID());
gr.query();
while(gr.next())
{
return gr.group.toString();
}
},

type: 'FillGroup'
};

 

but it is not filtering the groups 

You need to return a query string of all the groups:

var FillGroup = Class.create();
FillGroup.prototype = {
initialize: function() {
},
find_group:function()
{
var groups = [];
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user',gs.getUserID());
gr.query();
while(gr.next())
{
groups.push(gr.getValue('group');
}
return 'sys_idIN' + groups;
},

type: 'FillGroup'
};

Hi Uma,

Your code currently returns only 1 group. Fist you need to collect all group_ids of that user and store them in a array.

and then you need to pass it like this

return 'sys_idIN'+ your group_ids.

Hi Asif,

 

Thanks, Now when i look for roles, I need to pass selected group name as parameter while calling the function in reference qualifier, could you please help me with syntax of that ?

 

Thanks!

Uma

Hi Uma,

You can call like this

javascript:new FillGroup ().getGroupRoles(current.variables.your_group_var)