Hide item by user criteria, but allow the use by url
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2023 08:33 AM
Hi,
I need to hide an item (record producer) in the Employee Portal at the end to have this 3 possible configuration:
1- Users that see the item on the portal and use it
2- Users that not see the item by the portal but can use it by URL link
3- Users that can't see the item and can't use it
By the User Criteria I'm able to reproducer the possiblities 1 and 3
but not the the number 2.
How could I have all 3 functionalites ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2023 05:30 AM
Hi all,
I had found a partial solution that need to this 2 steps:
- A personalized link that point to the ITEM
- A new user criteria
The link wll store a new parameter on in it,
Something like this:
https ://devXXXXXX.service-now.com/sp?id=sc_cat_item&sys_id=3f0b3d68970765901cf9ff76f053afdd&sysparm_category=e15706fc0a0a0aa7007fc21e1ab70c2f&my_parm=true
The new user criteria (added to the item),
Will store this script:
var my_url =gs.action.getGlideURI()
if (my_url.get('my_parm')) {
gs.log('Ok URL '+my_url,'Vincenzo');
gs.log('Ok my_parm '+my_url.get('my_parm'),'Vincenzo');
answer = true;
} else {
gs.log('KO URL '+my_url,'Vincenzo');
gs.log('KO my_parm'+my_url.get('my_parm'),'Vincenzo');
answer = false;
}
I obtain perfectly the result that I want,
but it's like that the user criteria are evaluated only the first time.
If from a user (that are not allowed to see it) and after the log-in,
I use the link with "&my_parm=true" I see the item,
But now I'm able to see it also by the catalog navigation
If from a user (that are not allowed to see it) and after the log-in,
I use navigate the catalog, I can't see the item also by the link with "&my_parm=true"
there are some way the ask reset the evaluation of the UserCriteria ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2023 05:46 AM
you can't rely completely on the url and gs.action.getGlideURI() is not a good practice
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2023 06:05 AM
Hi Ankur,
I try to use the "gs.getUrlOnStack()" but I had a better result with the second one.
I undestand also that this could be introduce a security problem, becase same users that identify the parameters on the url could use it to access also to the other items that will had the same user criteria rule.
But I need to have the possibility to expose some item by direct link only for somebody users .
My second Idea, if I can't foud a solution with the user criteria rules, is to mange a copy of the idem that we need to expose by url.
In this way I will had:
1- an Item item that will be appear on the portal and that resped the user criteria rules
2- an item copyed by the first that not have user criteria rules and had the flag "hide_sp" and "no_search" setted to true
Do you think that the second idea could be better that the first one ? and why do you think that the "getGlideURI() " is not a good practice to use ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2023 06:22 AM
you can use it. I remember in the past we were being told to avoid using it.
I will suggest to have the 2nd idea to have copy of item
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader