- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2025 01:44 AM - edited ‎04-02-2025 03:12 AM
In portal, for a page under the "Can View" section, I mapped a user criteria for it.. and I used advance scripting over there.. and while testing I don't see logs are getting generated.. can anyone please help me to understand on why LOGS are not getting Generated? It makes me feel like user criteria it's self is not working..
answer = AccessValidation();
function AccessValidation() {
var UserID = gs.getUserName();
gs.info("Sathwik Entered");
var gr = new GlideRecord('sys_user');
gr.addEncodedQuery('user_name=' + UserID');
gr.query();
if (gr.next()) {
gs.info("Sathwik found");
return true;
} else {
gs.info("Sathwik not found");
return false;
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2025 01:52 AM
where did you add that? share screenshot
try this script
answer = AccessValidation();
function AccessValidation() {
var gr = new GlideRecord('sys_user');
gr.addEncodedQuery('sys_id=' + user_id);
gr.query();
if (gr.next()) {
gs.info("Sathwik found");
return true;
} else {
gs.info("Sathwik not found");
return false;
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
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-02-2025 04:54 AM
Glad to know. Remember to use user_id to get logged in user sysId and not gs.getUserID()
Thank you for marking my response as helpful.
If my response helped please mark it correct and close the thread so that it benefits future readers.
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-02-2025 08:32 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
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-03-2025 11:11 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.
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-02-2025 02:13 AM
Can you ensure the type of user_id? verify what its returning?
correct query on line number 4 as gr.addQuery('user_name', user_id);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2025 02:52 AM
syntactical errors are corrected, but still issue persits