cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dmonks
Level: Powered On

Access Page Context within a component

Is it possible to access the page context (at least the entity type and guid of the entity) within a field component. I can understand why you may not wish to make it generally available but it would be useful to offer the option to pass it as a parameter option.

 

 

15 REPLIES 15
PowerApps Staff HemantG
PowerApps Staff

Re: Access Page Context within a component

We are evaluating this ask, it would help if you can share some more details on the target scenario ?

 

As a workaround you can evlaute using input configurable properties. 

davallen
Level: Powered On

Re: Access Page Context within a component

Can you share where i would find this example or information? I am also trying to pass the id of the entity that my PCF is embedded on the form. This would be helpful if I want to show a custom visual that requires executing a FetchXml to query the aggregated data.

jdaraz
Level: Powered On

Re: Access Page Context within a component

I would like to see this too.

I have a control bound to a subgrid/dataset. I want to be able to create a new record in that dataset, but in order to do so I need to either:

1. Have the id of the parent entity so that I can use the webapi.

or 

2. Have a way to add a record to the dataset passed to the control.

It doesn't appear that I can do either?

 

Thanks

Jason

vigneshR
Level: Powered On

Re: Access Page Context within a component

 

Hi @dmonks@jdaraz@davallen,

 

If I am not wrong you could use below format to get the entity Id and EntityType of the form on which the custom control is added.

 

Capture_EntityrReference.PNG

 

you can refer below post for example code 

https://powerusers.microsoft.com/t5/PowerApps-component-framework/i-want-to-get-relevent-data-about-...

 

Please Feel free to mark the answer as verified if it is useful

Regards,

Vignesh.R

 

MinRao
Level: Powered On

Re: Access Page Context within a component

ScottDurow
Level 8

Re: Access Page Context within a component

There are actually two ways of getting the entityId and type name:

mode (https://docs.microsoft.com/en-us/powerapps/developer/component-framework/reference/mode)

 

context.mode.contextInfo.entityId
context.mode.contextInfo.entityTypeName
context.mode.contextInfo.entityRecordName

Or Page (not documented at all)

 

context.page.entityId
context.page.entityTypeName

Neither of these are documented. @HemantG Are either of these supported?

PowerApps Staff HemantG
PowerApps Staff

Re: Access Page Context within a component

This is in the back log and will be added in near future.  To unblock you can use in the interim  (not officially supported though)

context.mode.contextInfo.entityId
context.mode.contextInfo.entityTypeName

 

The final sematics will be communicated but are expected to be inline with above and hence control update should be straightforward. 

 

hemant 

ManishJain
Level: Powered On

Re: Access Page Context within a component

Have you tried declaring entityReference at the class level :

 

private _entity: ComponentFramework.EntityReference;

 

and later on in function this._entity.name, this._entity.id.guid to get the current record data . 

 

Thanks 

zsoltzombik
Level: Powered On

Re: Access Page Context within a component

Hello Scott,

 

I've tried to use context.mode.contextInfo.entityTypeName but I faced the following error message:

 

Property 'contextInfo' does not exist on Type 'Mode'

 

any workaround to get the EntityId and/or EntityName ?

Thx

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 305 members 5,899 guests
Please welcome our newest community members: