Reference qualifier - logged in user group membership
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 07:57 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 08:29 PM
what if logged in user is member of both or not member of both?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 08:30 PM - edited 04-11-2023 08:31 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 08:33 PM
then use this
Ensure you replace correct group1 sysId, group2 sysId and portfolio sysIds
javascript: 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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2023 01:22 PM
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.
Thanks,
Ben.