- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 10:23 AM
I am looking for assitance with away to create a user critiera profile based on the title of a users profile. I need to only allow users with "HR" in their title under their users profile to see a form in the service catalog. Is there away to use a script to get this to work?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 11:00 AM - edited 04-25-2024 11:08 AM
@EcFuhrmann The script which I have provided validates if the title contains "HR" (indexOf) and only those users will be able to access it.
Below is another e.g,
if (title.indexOf('vp') > -1 || title.indexOf('director') > -1 || title.indexOf('manager') > -1) {
return true;
}
return false;
}
Note: Converted the title to lowercase and have used in above "If" condition.
Please mark this as helpful and accept it as a solution if this resolves your query.
Thanks,
Sujatha V.M.
Sujatha V.M.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 10:28 AM
@EcFuhrmann You can create a "User Criteria" as below in advanced section add the script to identify the title and add it to the catalog item "Available For" related list.
checkCondition();
function checkCondition() {
var rec = new GlideRecord('sys_user');
rec.addQuery('sys_id', user_id);
rec.query();
if (rec.next()) {
var title = rec.getValue('title');
if (title == 'HR Executive' || title.indexOf('HR') > -1) {
return true;
}
}
return false;
Please mark this as helpful and accept it as a solution if this resolves your query.
Thanks,
Sujatha V.M.
Sujatha V.M.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 10:30 AM
Hi @EcFuhrmann ,,
Please check below thread -
If my reply helped with your issue please mark helpful 👍 and correct ✔️ if your issue is resolved.
By doing so you help other community members find resolved questions which may relate to an issue they're having
Thanks,
Astik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 10:54 AM
What do I do when the titles are not all the same and I want to use have it look if the title contains "HR"? These scripts are pointed to one title only.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2024 11:00 AM - edited 04-25-2024 11:08 AM
@EcFuhrmann The script which I have provided validates if the title contains "HR" (indexOf) and only those users will be able to access it.
Below is another e.g,
if (title.indexOf('vp') > -1 || title.indexOf('director') > -1 || title.indexOf('manager') > -1) {
return true;
}
return false;
}
Note: Converted the title to lowercase and have used in above "If" condition.
Please mark this as helpful and accept it as a solution if this resolves your query.
Thanks,
Sujatha V.M.
Sujatha V.M.