Reference Qualifier
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2023 12:13 PM
Hi,
I've created a reference field called " Test Group", I have this field referencing the user table, however I want to filter this field with users that only belong to group "xyz". How do I do this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2023 12:34 PM
You have to create Script include, In Script include return sys_id of users from Group XYZ.
Call that script include in Advance reference qualifier: Javascript: "sys_idIN:+comma separated sys_id return from script include.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2023 12:39 PM
There is a Group Member [sys_user_grmember] table that contains the groups and their respective users. So, I would suggest you to use sys_user_grmember as reference table instead of referencing the user table and apply the condition as shown in the screenshot below.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2023 12:55 PM
You could do a couple different things. I think most people would prefer using a Script Include to return a particular query, but you could use a related list query instead. Since this is just one group, that's simple enough that a related list query could be used.
Here is an example:
- Dictionary Entry for Reference column
- Reference Specification section
- Reference = User
- Use reference qualifier = Advanced
- Reference qual condition = active=true^RLQUERYsys_user_grmember.user,>=1,m2m^group=ca5922a4db27e2009aa8d604ce9619d9^ENDRLQUERY
- Save
My PDI keeps saving this back as using a Simple reference qualifier, but the XML shows the full query I put in the text box when Advanced was selected. Changing to Advanced still shows the full query as well so I can amend it as needed. This way, I am getting all active users in the group "Showcase Manager User Group" which is only 20 users. You should be able to use my exact filter and just change the group sys_id to the one you need.
Question: How do I know what the RLQUERY will be if I want a different related list or query?
Answer: You can create a report that returns the results you want using the RELATED LIST CONDITIONS section of the filters applied. When you view the XML of the saved report from the sys_report table record, the <filter> element will show you. This is the easiest way.
If you want to use a script include instead, by all means go for it. This would be an Advanced reference qualifier with the Reference qual condition = javascript: myScriptInclude().my_refqual(). Documentation here.