I have a custom page(using Canvas app) in my Modern Driven App. I have few fields in the custom page. How can i read the values of those fields using API like XRM or FormContext.
I'm not able to read using Xrm. Is there any other way to acheive this?
Loading

Naimish MakwanaPosted Jun 11, 2024, 6:51 AM
Yes, there is a way to read the values of fields using the
FormContextAPI in Dynamics 365 Power Apps. TheXrm.Pageobject has been deprecated in Dynamics 365 v9.x, and it’s recommended to use theFormContextobject instead1.Here’s an example of how you can use
FormContextto read field values:In this example,
executionContext.getFormContext()is used to retrieve theformContextobject. Then,formContext.getAttribute("fieldname").getValue()is used to get the value of a field1.For a web resource in Dynamics 365 Power Apps, you can use
getContentWindowin the Client API. Here’s an example:In this example,
formContext.getControl("WebResource_MyWebResource")is used to get a reference to the web resource control. Then,wrControl.getContentWindow()is used to get a reference to the content window of the web resource. ThesetClientApiContext(Xrm, formContext)function is then called on the content window2.Please replace
"firstname","lastname", and"WebResource_MyWebResource"with your actual field names and web resource control name.Remember to select the “Pass execution context as first parameter” option in the Handler Properties dialog while defining your event handlers to use the
formContextobject1.Thanks