- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2023 10:36 AM - edited ‎12-07-2023 12:10 PM
I have an interesting question. I am building a front end portal page that allows portal users to search for users with skills. I got how to handle if a user has one skill, but what about multiple? Lets just say you want to find someone who codes in Python AND Java, how would you be able to search the search the "sys_user_has_skill" table to return records where a user has both skills "Python" and "Java", and with one gliderecord/glideaggregate call (for repeatability). I know you can do that with tags, but not sure with skills.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2023 10:13 PM
HI @kcouvillon ,
I trust you are doing great.
Here is an example of how this could be implemented:
// Function to find users with both Python and Java skills
function findUsersWithBothSkills() {
var pythonUsers = getUsersWithSkill('Python');
var javaUsers = getUsersWithSkill('Java');
// Find users who are in both lists
var usersWithBothSkills = [];
for (var i = 0; i < pythonUsers.length; i++) {
if (javaUsers.indexOf(pythonUsers[i]) > -1) {
usersWithBothSkills.push(pythonUsers[i]);
}
}
return usersWithBothSkills;
}
// Function to get user IDs for a given skill
function getUsersWithSkill(skillName) {
var userIDs = [];
var gr = new GlideRecord('sys_user_has_skill');
gr.addQuery('skill.name', skillName);
gr.query();
while (gr.next()) {
userIDs.push(gr.user.toString());
}
return userIDs;
}
var users = findUsersWithBothSkills();
gs.info('Users with both Python and Java skills: ' + users.join(', '));
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-11-2023 04:13 AM
That is close to what I was thinking for an alternative to what I am looking for. I was hoping to find a way to do it with one glide call so we do not have to query all users and all tags (which will eventually get very large), plus I can just retrieve the specific subsets of the results that I need with results with chooseWindow to make it less resource intensive.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2025 04:34 AM
That should work!