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;
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 @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:
@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.
Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.
Fill out a quick form to claim your user group badge now!
Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities
Features releasing from October 2019 through March 2020
Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.
Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications