- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2024 01:15 AM
good morning,
we have in our incident form two fields (assigned group and assigned to) where the system filters only matching records if one field is filled with data. this works vice versa.
i would like to use this now in an catalog item where i need exactly the same fileds (user and group) to be filtered.
we have three tables --> sys_user sys_user_group and sys_user_grmember,
do you have any hints for me to lets say copy the behaviour of the incident fileds 😄
kind regards
Oliver
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2024 01:28 AM
Hi @xlarge74 ,
Similar question i have answered please check the below article,
You can do the same for catalog item just change the field names accordingly,
Please check and Mark Helpful and Correct if it really helps you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2024 03:57 AM - edited 06-26-2024 04:00 AM
Hi @xlarge74 ,
try below script include and use on groups reference qualifier
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2024 01:16 AM - edited 07-02-2024 12:29 AM
Good morning, i found out how to do it 🙂
i just filtered in the group table and copied the query and added the "group." to access the attributes of the group object.
Maybe i can help somebody else with this finding 😄
var tfGetUserGroups = Class.create();
tfGetUserGroups.prototype = {
initialize: function() {},
getGroups: function(userId) {
if (userId) {
var groupsArr = [];
var grUsrMem = new GlideRecord('sys_user_grmember');
grUsrMem.addEncodedQuery('user=' + userId);
grUsrMem.addEncodedQuery("group.type=1cb8ab9bff500200158bffffffffff62^group.active=true");
grUsrMem.query();
var arr =[];
while (grUsrMem.next()) {
groupsArr.push(grUsrMem.group.getValue());
}
return 'sys_idIN' + groupsArr;
}
},
type: 'tfGetUserGroups'
};
The javascript for the reference qualifier (group):
javascript: new tfGetUserGroups().getGroups(current.variables.u_durchfuehrende_person);
BTW: The "javascript:" doesnt work in my environment. I had to switch it back to "javascript:"
Here is what it does:
I have a user field (u_durchfuehrende_person) which is entered by the user.
The next filed is the group field. There should only groups be shown, which are assigned to the user. Second step is to show just the groups with the type 'itil' and active=true. This encoded query was done via the group table filter. The query was copied and put in the addEncoded query in my script. To access the attributes of the group i just added group. in front of the attributes (as seen in the code example). et voila 😄 I´m so happy now thanks to swathisarang98 and Pavankumar_1 who led me to the solution.
kind regards
Oliver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2024 01:57 AM
Check the reference qualifiers of the fields in the Incident table and apply the same reference qualifiers to the corresponding variables in your catalog item.
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2024 11:42 PM
good morning
i tried, but the mechanics between incident and catalog item are slightly different 😞
kind regards oliver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2024 02:07 AM - edited 06-20-2024 02:14 AM
Hi @xlarge74
Add below code in Reference Qualifier
javascript; new scriptIncludeName().getUsers(current.variables.assignment_group);
getUsers : function(grGroup) {
var arr =[];
var grUsers = new GlideRecord('sys_user_grmember');
grUsers.addEncodedQuery('group='+grGroup);
grUsers.query();
while(grUsers.next())
{
arr.push(grUsers.user.getValue());
}
return 'sys_idIN'+arr;
},
Note: Replace scriptIncludeName with your Script Include Name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2024 12:21 AM
dear sunil,
i´m sorry for my late reply.
if im searching for the groups the user is attached to i have to rewrite this right?
for example:
first field im entering the user
second filed should only show the groups with type 'itil' from this user
kind regards
oliver