User Criteria for Matching Job Titles
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2024 09:42 AM
Hi Community,
I have a requirement to add a user criteria for employees that have certain parameters in their job titles to restrict certain catalogue items to only those members of staff. As this is a field on the user table itself and not another reference field I believe I will need to create a script for this rather than extending the user criteria (as it's not a reference field.
I have tried the below with the addition of some logging (at which point returned title:null)
(function() {
// Get the user's job title
var user = gs.getUser();
var jobTitle = user.getRecord().getValue('title');
// Check if the job title contains "director", "head of", or "manager"
if (jobTitle) {
jobTitle = jobTitle.toLowerCase(); // Convert to lower case for case insensitive comparison
if (jobTitle.includes('director') || jobTitle.includes('head of') || jobTitle.includes('manager')) {
return true;
}
}
return false;
})();
So question is - is this the right method and what am I missing if so.
User criteria diagnostics are showing that users with job titles 'manager' etc do cannot view the catalog item i have added the user criteria record to.
Getting the correct answer will also help with potential additional requirements based of user attributes.
Any help greatly appreciated.
Many thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2024 12:02 PM
Hi @k_21
I would agree this is the right method.
Your script worked as expected when i tried on my PDI, however, if i cleared the logged in users title it returned 'null'.
Please confirm the user has a title 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 02:58 AM
Thanks @Jon23 . I think the null title was an error of mine. I can confirm that all users have valid titles.
Interestingly I have ran the user diagnostic against multiple users I believe should be returning true and there is 1 example of where that it is the case as attached shows.
Any users with a combination of 'xyz manager', Director, XYZ', 'XYZ Director' do not return.
It is even the case that another user with title (not one shown in example) 'Head of' returns false.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 10:45 AM
Hi @k_21
I am wondering if you're experiencing the issue described in SN KB0750243: User Criteria Diagnostics tool results inconsistent with actual user experience
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 12:28 PM
Many thanks @Jon23 I did wonder whether there was any errors with the diagnostic tool, but unfortunately when impersonating the users I see the same results.