How to Dynamically show/ hide buttons on entity list grid in PowerApps portals

I am working on PowerApps project for my customer and recently I got a requirement to show/ hide buttons on entity list item depending on condition.

To explain the requirement in more detail, I have the following action buttons on my entity list grid.

Show hide buttons dynamically in entity list in PowerApps portals

View details and Edit record are the two action buttons I have for the entity list grid item. Now the requirement here is to show the edit details button if the Relationship column value is Parents only.

The first thing that come to your mind if write some custom javascript on onload of the entity list and show/ hide the buttons dynamically based on data. Can we accomplish the same? Yes we can. In-fact with very complex logic, that is sometimes the only option.

But wait, before we go that route, we have something available in the platform as well. In fact Power apps portals provide filter queries where you can write fetchxml for conditional display of your buttons. But the problem is, very few are aware of this. And the reason is it’s a hidden option until you check on Advanced Settings option (highlighted in screenshot below).

Show hide buttons dynamically in entity list in PowerApps portals

After I check the box, you can now see the Filter criteria textbox.

Show hide buttons dynamically in entity list in PowerApps portals

Let’s go ahead and complete our requirement here.

Below is my fetchxml

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="cr444_visitrequest">
    <filter type="and">
      <condition attribute="cr444_relationship" operator="eq" value="304290001" />
    </filter>
  </entity>
</fetch>

The condition provided is to filter only for Relationship = Parents for my condition. Please remember to put the entire fetchxml and not just the filter critera.

After I put this condition in the filter criteria for the button, the Edit button is not shown for any other relationship other than parent.

Show hide buttons dynamically in entity list in PowerApps portals

Before I end one info. The columns specified in the filter criteria does not need to be in the view for this functionality to work. So even if I remove the relationship column from the view, it should just work fine.

Hope this helped!

Debajit Dutta
Business Solutions MVP


Discover more from Debajit's Power Apps & Dynamics 365 Blog

Subscribe to get the latest posts sent to your email.

Discover more from Debajit's Power Apps & Dynamics 365 Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading