- 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-07-2023 03:37 PM - edited ‎12-07-2023 03:37 PM
Just some ideas that came to mind....Tags would be the way to go. You could create some sort of automation that automatically adds the name of the Skill the user is assigned to in the tags when the Skill record changes for the sys_user_has_skill record. The instances of tags being applied are stored in the label_entry field, so you'll essentially be creating a record there. You could then search the label_entry on the portal (but limit the search query to just Skill records).
If you want a search functionality that behaves like Tags does when you add a new Tag to a record in a list view then you will need to create some custom widget to do that.
Consider the above and also take a look at the kb_search Portal Page and the kb-search Widget on that page. Those will give you some inspiration for how you could make work and tie it all together.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-11-2023 04:07 AM
My initial idea was to use tags (which I completely built out that way at first), but we also use tags for request's/incident, changes, exc.... We start using this for users also then it will make if very hard to find tags for the rest of it, plus skills is more best practice for identifying who can do what.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-11-2023 09:10 AM
How are you using tags currently for ITSM tickets? You could also add an additional
'Type' to the Tag record to differentiate between ITSM tags and Skill tags.
- 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