- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2020 01:56 AM
I have a custom widget created in the service portal. I have activated the plugin for User criteria in the portal. Users occupying a specific field in the user table should have access to the widget. But the user criteria script is not working and everybody in the user table is able to view the widget. Can anyone please help? It is an urgent requirement.
var gr = new GlideRecord('sys_user');
gr.addActiveQuery('manager', gs.getUserID());
gr.query();
if(gr.next()){
answer =true;
}
else{
answer = false;
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2022 07:12 AM
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2020 02:42 AM
Hi,
Can you confirm that you performed these steps:
1. Activate the plugin (com.glide.service-portal.user-criteria)
2. Set the user criteria for Service portal system property
3. Create a user criteria for Service Portal
Script:
answer = ifScript();
function ifScript() {
var userId = gs.getUserID();
var user = new GlideRecord("sys_user");
user.addActiveQuery();
user.addQuery('manager', userId);
user.query();
return user.hasNext();
}
4. Apply user criteria for to a page,widget or widget instance
If I have answered your question, please mark my response as correct and/or helpful.
Thanks,
Suseela P.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2020 04:09 AM
Hi Muktha,
I think the query should be like this; if the logged in user is manager of any user
var gr = new GlideRecord('sys_user');
gr.addQuery('manager', gs.getUserID());
gr.query();
if(gr.next()){
answer =true;
}
else{
answer = false;
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2021 01:34 AM
Hope you are doing good.
Did my reply answer your question?
If so, please mark appropriate response as correct & helpful so that the question will appear as resolved for others who may have a similar question in the future.
Thanks!
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2021 03:08 AM
Hope you are doing good.
Did my reply answer your question?
If so, please mark appropriate response as correct & helpful so that the question will appear as resolved for others who may have a similar question in the future.
Thanks!
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Hope you are doing good.
Did my reply answer your question?
If so, please mark appropriate response as correct & helpful so that the question will appear as resolved for others who may have a similar question in the future.
Thanks!
Ankur