Service Portal/Pages user criteria for NOT logged in users
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2020 07:24 AM
Our team has created a public portal (url suffix 'public_portal') and a employee dashboard portal (url suffix 'employee_dashboard'). The public portal should be available for anyone to view and has a place for users to log in. Once a user logs in from the public portal, they will be directed to the employee dashboard portal. We do not want users to be able to navigate back and forth from each portal by typing in the url for the pages as each portal has a specific theme. We've activated the User Criteria for Service Portal plugin and want to create a User Criteria so that only not logged in users can view the public_portal. We created an advance User Criteria and tried
!gs.isLoggedIn();
which did nothing. We also tried the following found from another community post, which also did not work:
condition = answer();
function answer(){
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', gs.getUserID());
gr.addActiveQuery();
gr.query();
condition = gr.hasNext();
return condition;
}
Is there a way to limit a portal to only be viewable to public users (aka users not logged in)? We understand that we probably have to mess with login rules and routing to get users from the public portal to employee dashboard and vice versa, but as a first step we want to see if we can prevent logged in users from being able to view the public portal. Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2020 07:37 AM
There is a checkbox on the page to mark it public. You then have to remove all of the user criteria if memory serves.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2020 08:04 AM
Thanks Drew, those pages are public, but the issue is we don't want logged in users to be able to enter the public page names in the url and view the page with the employee_dashboard theme. Right now a user can go to the public portal by typing in the url: servicenowinstance.com/public_portal?id=landing_page. Once they log-in from there, they will be directed to servicenowinstance.com/employee_dashboard. However, if they wanted, they could type in servicenowinstance.com/employee_dashboard?id=landing_page and view the public page with the employee_dashboard theme. We don't want that scenario to happen. Any thoughts?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2020 09:12 AM
Create a widget that checks to see if they are logged in and if they are simply send a redirect to the client. Then put that widget at the top of the page. It may start to render but then redirect them. Not sure you will be able to do anything else since the page is public.