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 / List Filter Criteria f...
Power Pages
Answered

List Filter Criteria for Edit Button based on Current Portal User

(0) ShareShare
ReportReport
Posted on by 23

Hi,

I have a question about the capabilities of the Filter Criteria FetchXML on entity list buttons.

My scenario involves showing an Edit button next to an Entity List record if the record's Contactid matches the Current Portal User.

 

Capture.PNG

 

I have tried the following FetchXML in the Filter Criteria:

 

 

 

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
 <entity name="test_contact">
 <attribute name="test_contactid" />
 <attribute name="test_name" />
 <attribute name="test_createdon" />
<link-entity name="systemuser" from="systemuserid" to="test_contactid" link-type="inner" alias="ad">
 <filter type="and">
 <condition attribute="systemuserid" operator="eq-userid" />
 </filter>
</link-entity>
 </entity>
</fetch>

 

 

 

However this did not work (as it's wrong).

Is there an attribute which stores the ID of the currently logged in portal user?

 

I haven't come across anyone else trying to achieve this functionality so any help would be appreciated.

Thanks

 

Categories:
I have the same question (0)
  • Saud Ali Profile Picture
    812 Super User 2024 Season 1 on at

    Hi @Adx_Harry ,

     

    Couple of things after reading your scenario what you want to achieve. 

     

    1. Portal by default does not save reference of Portal User when you create a record from Portal until you've configured it. After you configured this, now each record created from Portal will have reference of logged in user and then you can filtration.
    2. Why don't you achieve this using table permissions? Like show only those records which belong to Portal logged in user. You can do this using Table Permissions in Power Pages.

    Feel free to ask, if you have any questions.

     

    Thanks,

    Saud

     

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • Fubar Profile Picture
    8,487 Super User 2026 Season 1 on at

    Not sure if you will be able to do what you want (other than by Web Role/Table Permissions), but your fetchXML is not correct - the Portal User is the dataverse Contact record not the User (systemuser) record. 

  • Adx_Harry Profile Picture
    23 on at

    Thanks for the help!

    I should have mentioned, the functionality I'm trying to recreate is that of a forum. Any user can create a post and all the other posts are visible however, they can only edit their own posts.

     

    Would using table permissions hide all the other user's posts?

  • Adx_Harry Profile Picture
    23 on at

    Thank you,

    My FetchXML was mostly an experiment so I realise its quite wrong. I'll explore the use of table permissions, however finding a solution that uses the Filter Criteria seems quite elegant to me.

    I haven't found a method of comparing the active Portal User's contact record to the Contact record on my Entity List yet

  • Saud Ali Profile Picture
    812 Super User 2024 Season 1 on at

    Hi @Adx_Harry ,

     

    Got your point, in that case what you can do is you can configure logged in Portal user reference to each Post in an additional column (e.g, Portal User (Contact Lookup)) which gives you flexibility to add this column as a condition in your FetchXml. 

     

    Please check out this post for reference:

     

    https://readyxrm.blog/2019/08/26/powerapps-portals-how-to-hide-or-show-content-based-on-logged-in-user/ 

     

    Feel free to ask, if you have any questions.

     

    Thanks,

    Saud

     

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

     

     

  • Adx_Harry Profile Picture
    23 on at

    Thanks for the quick reply,

    I already store a reference to the Portal User's contact in my entity, however I don't know how to compare it using FetchXML to the current Active Portal User.

     

    For example:

    Say in my entity I have PortalContactID, and this stores Contact ID of the Portal User which created the forum post.

    Next I want some FetchXML in the Entity List's Filter Criteria.

    I want to compare the PortalContactID to the Active Portal User's Contact ID.

     

    But how would I go about doing this using FetchXML?

     

    I know I can do it using Liquid, fetching the associated Contact of {{user.id}} and injecting HTML if it matches.

    I want to test the capabilities of the Filter Criteria. This may simply be impossible, however it is worth exploring.

  • Saud Ali Profile Picture
    812 Super User 2024 Season 1 on at

    Hi @Adx_Harry ,

     

    If you're already saving contact reference then all you need to do is just get user id from user object available in Power Pages and pass it to your fetchXml. Here is an example how to do it:

     

    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
     <entity name="posts">
     <attribute name="name" />
     <filter type="and">
     <condition attribute="PortalContactID" operator="eq" value="{{user.id}}" />
     </filter>
     </entity>
    </fetch>

     

     

    Thanks,

    Saud

     

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • Adx_Harry Profile Picture
    23 on at

    Sadly, this still doesn't work. I wonder if its a limitation of the Filter Criteria box to run Liquid.

    I wonder if there is an adx_ attribute or something.

  • Saud Ali Profile Picture
    812 Super User 2024 Season 1 on at

    Hi @Adx_Harry ,

     

    Have you tried to pass FetchXml hardcoded Guid instead of retrieving it based on logged in user? I'm unsure about executing liquid in filter criteria box may be that's why its not working in your case. If you can prepare one sample FetchXml with same user logged in and test to see if it works for you or not. 

     

    For reference, please check this article.

     

    Thanks,

    Saud

     

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • Adx_Harry Profile Picture
    23 on at

    It works with a hard-coded GUID but not using the liquid {{user.id}}.

    I would need another way of retrieving the Current Portal User without using Liquid. I'm wondering if this is even possible.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
DP_Prabh Profile Picture

DP_Prabh 51

#2
rezarizvii Profile Picture

rezarizvii 35

#3
oliver.rodrigues Profile Picture

oliver.rodrigues 29 Most Valuable Professional

Last 30 days Overall leaderboard