Check if "Requested for" account CONTAINS specific value in User criteria script
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2024 08:05 AM
Hi all,
I am limiting the visibility of catalog items with an user criteria by role, but at the same time I want to check the "requested for" to see if its name CONTAINS "-ADM", if so, allow the catalog item to be requested.
This is my script, but it isn't working (user is not allowed to be request the catalog item where the user criteria applies):
answer = ifScript();
function ifScript() {
var userObject = current.getValue("requested_for");
if (userObject.indexOf("-ADM") > -1) {
return 'yes';
} else
return 'no';
}
any help will be appreciated!
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2024 08:11 AM
requested_for is a reference and would give you a sys_ID and if you try getValue(). Could you try getDisplayValue() method instead?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2024 08:19 AM
Hi @Sue143,
Please try the updated code.
answer = ifScript();
function ifScript() {
var userObject = current.getValue("requested_for").getDisplayValue();
if (userObject.indexOf("-ADM") > -1) {
return true;
} else
return false;
}
-Thanks,
AshishKM
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution