Announcements
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:
Those properties are not contained in the typings. Is it safe to use them? What is the alternative since Xrm.Page is deprecated?
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;
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.
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).
Hi @ben-thompson ,
Thanks for your reply. Didn't think about that possibility, to be honest. Will update my post to notify about this.
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,
@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.
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
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.
Congratulations to our 2026 Super Users!
Congratulations to our 2025 community superstars!
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Vish WR 914
11manish 627
Valantis 598