reference qualifier script member of group

Karen Warren
Tera Contributor

This has come up for me enough times and I don't want to continue to rely on our outside implementers.

I need to create a reference qualifier that is scoped to a particular group. Can someone let me know what that script would look like? I thought I was close a couple times, but I keep missing it.   sys_user field that references only a particular group.

This would be a big help.

Thanks,

Karen

13 REPLIES 13

Well what I wanted was a workaround for another problem:


I needed to be able to select inactive users on a certain form and I couldn't figure out how to adjust the BR on te sys_user table that prevents inactive users to be shown (BR: 'user query').


Therefor I thought up a workaround to add all those users to a specific group and hopefully bypass that BR like that...


But after _more_ searching I finally found the correct code for the BR (just posting it for completeness) :



var str = gs.action.getGlideURI().toString();


if (str.indexOf("3dc5ecc2823739ce08ac0b84f643990ec2") >= 0 || gs.hasRole("admin")) {


} else {


      current.addActiveQuery();


}



So thanks for thinking with me, but my problem is solved


Glad to be of help... and thanks for making my case-in-point   .   It's always better to look at the whole picture than just the small bit you're working on, because the problem you have may not be a problem at all... merely a wrong turn.




Thanks,


-Brian


Hi, Can I do something like this on a catalog variable.   I am asking for a user's name and I want the next variable of groups to show me only the groups that user is a member of.



My user's variable is peer_reviewer and my groups is peer_group.



Can I do it with a reference qualifier on the group or do I need to write a client script?



thanks,


Stacy


Hi Stacy,



Sure, you can setup a similar Reference Qualifier for variables... For your peer_group variable definition, choose to use an Advanced reference qualifier.



In the Reference qual field, enter:



RefQual:


javascript:var vars=current.variables;var gr=new GlideRecord('sys_user_grmember');var gps;gr.query('user',vars.peer_reviewer.sys_id);while(gr.next()){gps+=gr.group.sys_id +','};'sys_idIN'+gps;




The problem you can run into here is that the RefQual field has a limited length, so as you start writing a lengthier javascript statement, you may have to save it in a Script Include and call that from your RefQual (e.g.):



Script Include:


function myRefQual(record){


var vars = record.variables;


var gr = new GlideRecord('sys_user_grmember');


var gps;


gr.query('user', vars.peer_reviewer.sys_id);


while(gr.next()){


gps += gr.group.sys_id + ',';


}


return ('sys_idIN' + gps);


}



RefQual:


javascript:myRefQual(current);




Give that a try and see.   And check my script for typos before you copy/paste... I didn't test this in-situ, just wrote it up here.




Thanks,


-Brian