cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ScottDurow
Level 8

Re: Access Page Context within a component

That is odd - it always has worked for me.

The other way I've seen it done is:

context.page.entityId

but apparently this isn't going to be the supported way.

DanzMaverick
Level: Powered On

Re: Access Page Context within a component

I have been using below code to access entityId and entityTypeName

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

But I had to use

@ts-ignore

to make it work.

zsoltzombik
Level: Powered On

Re: Access Page Context within a component

Thanks,

 

It's working. Anyway can I access the Form context in the same way ?

 

var formContext = executionContext.getFormContext();

// get formContext // use formContext instead of Xrm.Page

var firstName = formContext.getAttribute("firstname").getValue();

var lastName = formContext.getAttribute("lastname").getValue(); console.log(firstName + " " + lastName);

ManishJain
Level: Powered On

Re: Access Page Context within a component

If you have to access the fields why not use manifest file and use them in control and you can bind them back if you need manipulation to be done and then send it to fields .

ScottDurow
Level 8

Re: Access Page Context within a component

@zsoltzombik Using the formContext in this way isn't supported - although it does work. 

The intension is for the PCF component to be decoupled from the form and only use the parameters to pass data back and forth.

That said, some attribute types are not supported such as Lookups (coming soon), ActivityParty, Customer Fields.

 

For theses, the 'official guidance' is to use a text field to serialise the values back and forth - but that is really awkward and personally until they are supported, I think it's fair to use the form context *for those specific field types* until then - it will be easy to replace out the code once supported.

ScottDurow
Level 8

Re: Access Page Context within a component

It's worth re-inforcing that the the form context won't be there when embedding in Canvas Apps - perhaps stating the obvious!

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: 143 members 5,372 guests
Please welcome our newest community members: