Reference qualifier - logged in user group membership

Ben42
Tera Contributor

Hello Experts,

I have a reference field called ‘Portfolio’ on projects with ‘portfolio 1’ and ‘portfolio 2’ . The requirement is if the logged in user from “Group 1” the user should only see “portfolio 1” in the “Portfolio” reference field. Similarly if the user is from “Group 2” the user should see only “portfolio 2”.  

how should the reference qualifier script be?

 

Thanks in advance.

Ben.

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@Ben42 

what if logged in user is member of both or not member of both?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

 

if user is member of both groups, they should see both portfolios.

 

if not member of either of the groups they can’t access our module at all. so this use case is good.

 

Thanks,

Ben.

@Ben42 

then use this

Ensure you replace correct group1 sysId, group2 sysId and portfolio sysIds

javascript&colon; var query; var groups = new global.ArrayUtil().convertArray(gs.getUser().getMyGroups()); if(groups.indexOf('Group1 SysId') > -1) query = 'sys_id=<portfolio1 SysId>'; else if(groups.indexOf('Group2 SysId') > -1) query = 'sys_id=<portfolio2 SysId'; else query = 'sys_idINportfolio1sysId,portfolio2sysId'; query;

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hello Ankur,

There is ootb reference qualifier on the 'portfolio' field. Fyi, My requirement is regarding the 'Teamspace' where the Teamspace is extending project table and already has ootb ref.qual on 'portfolio' field. 

How can I try your script with existing ref.qual (below).? Please help.

Ben42_1-1681330857072.png

 

Thanks,

Ben.