Hide container in portal based on user record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2020 05:28 AM
I have a user-defined field on the sys_user table. Based on this field I would like to show/hide containers on the home page of our portal. As I understand it, you cannot OOB hide a container based on user criteria, so what is the best way to do this? Should I add a script to that portal page that checks this value and shows/hides the DOM element accordingly? As I understand it, this method is not advised. So what is advised? And if I am creating a script on the page, how do I check that value from the server?
- Labels:
-
Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2020 04:59 AM
Still in need of help here. Again, the user criteria plug-in does not allow you to hide a container. I assume I am going to have to script something. What is the best practice for this, and how do I access the user-defined field on the sys_user table to know which containers to show/hide?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2020 05:21 AM
I am going to use DOM manipulation to hide the container. I was trying to avoid that, but I have not yet found a better way.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2020 05:31 AM
Hey David,
Inspect the element by using the browser's developer options and get the 'id' attribute of the container. And then use the following JavaScript code to hide/show the container.
Code: document.getElementById("inspected id comes here").style.display = "none";
document.getElementById("inspected id comes here").style.display = "block";
Or you can use this script-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2020 06:39 AM
I put similar code in a JS Include for the theme, but it is not working yet. To clarify: this is the home page of the portal where I want to show/hide containers. I want to do this based on a user-defined field in the user table. I haven't even gotten to the point yet of passing that information from the user table. Right now I am just trying to see if I can change the display setting of container elements, but so far no luck.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2020 07:30 AM
It appears that the containers do not have ids. I thought I could hide them by assigning them a class and using jquery to hide that class, but that doesn't work.