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 Apps / How to access entityId...
Power Apps
Unanswered

How to access entityId and entityTypeName inside component

(2) ShareShare
ReportReport
Posted on by 13

What is the correct way to get entityId and entityName of the record the component is located on? From inspection of the context object I have found, that there is:

  • page.entityId
  • page.entityTypeName

Those properties are not contained in the typings. Is it safe to use them? What is the alternative since Xrm.Page is deprecated?

I have the same question (0)
  • Ben Thompson Profile Picture
    1,400 on at

    I believe it will eventually become available from within  context.mode.

     

    For the moment the best approach is to use

     

    let entityId = (<any>context.mode).contextInfo.entityId;
    let entityTypeName = (<any>context.mode).contextInfo.entityTypeName;

     

  • OOlashyn Profile Picture
    3,498 Most Valuable Professional on at

    Hi @Marius ,

     

    There is no OOB way for now. I wrote an article about a workaround about how you can get this information in Model-driven app. A bit of an overkill, however not depend on the undocumented parts of the PCF. You can find it using this link.

  • Ben Thompson Profile Picture
    1,400 on at

    Sadly the url may not be accurate - in the unified interface it’s possible that the url will relate to the form as a whole while the PCF may be sat in a card belonging to a reference entity (for instance the primary contact card within the account record).

  • OOlashyn Profile Picture
    3,498 Most Valuable Professional on at

    Hi @ben-thompson ,

     

    Thanks for your reply. Didn't think about that possibility, to be honest. Will update my post to notify about this.

  • v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @Marius ,

    I agree with @OOlashyn 's thought almost. Currently, within PowerApps, there is no client API supported in PowerApps Component Framework to get the entityId and entityTypeName of current record.

     

    As an alternative solution, please consider take a try with the alternative solution provided by @OOlashyn , then check if the issue is solved.

     

    If you would like this client API to be added in PowerApps Component Framework, please consider submit an idea to PowerApps Ideas Forum:

    https://powerusers.microsoft.com/t5/Power-Apps-Ideas/idb-p/PowerAppsIdeas

     

    Best regards,

  • Ben Thompson Profile Picture
    1,400 on at

    @v-xida-msft and what happens as we follow the roadmap and the form / context of the field is in a parent / child record of the record referenced in the url.

     

    I think even back in the 2015/6 days (well before even web refresh) the product team recommended not using the URL to identify the entity being used simply because it might not be 100% accurate.

     

    I'm not happy having to comment on a post from a microsoft representative but just because something isn't quite available through the documented API, doesn't make an architecturally unsound approach with known flaws and well documented edge cases a better solution.

  • Hemant Gaur Profile Picture
    Microsoft Employee on at

    Agree @ben-thompson that URL is not the right way. This is currently missing feature in PCF as it needs some design on how these properties will be working on canvas and other model surfaces like grids and dialogs.  We are actively evaluating options here and will share the recommendation on this soon so that there is a established pattern until we add official support.  Priority of the issue is acknowledged.

     

    hemant  

  • Tim Robinson Profile Picture
    50 on at

    Fortunately in 2023 there is now a better way - you can bind the entity id and/or entity type (now called row id and table name) to any PCF control property of type "SingleLine.Text"

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 Apps

#1
Vish WR Profile Picture

Vish WR 914

#2
11manish Profile Picture

11manish 627

#3
Valantis Profile Picture

Valantis 598

Last 30 days Overall leaderboard