web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Entity List View Selec...
Power Pages
Answered

Entity List View Selector - Would like to hide a view with javascript

(0) ShareShare
ReportReport
Posted on by 5

Hello,

 

I have an entity list which has 3 views in the view selector. I would like to hide views based on the user's web roles with javascript. I am able to capture the web roles from a liquid tag, but cannot figure out how to hide an individual view. The sample code i get with Copilot is:

 

$(document).ready(function() {
// Wait for the entity list to load
  $(".entitylist").on("loaded", function() {
    var roles = '{{ user.roles }}'; // Get the user's roles
    console.log(roles);
    // Find the dropdown menu for views
    var viewDropdown = $(this).find(".view-select");
 
    // Find the option for the view you want to hide and hide it
    viewDropdown.find('option[value="Portal Teachers - System-Wide"]').hide();
  });
});
 
The view does not hide. I would like to do this without creating a web template which is a suggestion in another post. Is this possible?
Categories:
I have the same question (0)
  • Verified answer
    Fubar Profile Picture
    8,528 Super User 2026 Season 1 on at

    The bit that does the hiding in your code is not correct.  The following can probably be refined a bit, AND you will also have to handle the case where the view is the currently selected view also. 

    Not using the variable at all, something similar to 

     

     

    $("#filterDropdownId ul.dropdown-menu li a[aria-label='Portal Teachers - System-Wide']").parent().hide();

     

     

     

     

  • Jazzy4321 Profile Picture
    5 on at

    That worked perfectly as is. Thanks so much!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
sannavajjala87 Profile Picture

sannavajjala87 38 Super User 2026 Season 1

#2
Valantis Profile Picture

Valantis 35

#3
Fubar Profile Picture

Fubar 23 Super User 2026 Season 1

Last 30 days Overall leaderboard