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

PCF Refresh Form

Is there any way to refresh the current page, if for example I have made updates to something via the webAPI?

 

I suppose I could context.navigation.openForm({  }) the current record, but that seems a bit hacky, is there any supported way to refresh the current page?

1 ACCEPTED SOLUTION

Accepted Solutions
PowerApps Staff HemantG
PowerApps Staff

Re: PCF Refresh Form


@ScottDurow wrote:
This approach - whilst would work introduces some negative coupling between form JavaScript and the PCF component. A maker wouldn’t be able to just add a control to their form - they would also need to write JavaScript and know how the control works.

Ack the pain point here , we are working on the plan to address it more graceful and generic manner. We will make details available when ready.

 

thanks,

Hemant 

View solution in original post

8 REPLIES 8
a33ik
Level: Powered On

Re: PCF Refresh Form

@NickDewitt I believe there is no good and supported way of doing it because your control can be located on "Quick Create" or "Quick View" form. Your approach looks a bit hacky but anyway should work.

ScottDurow
Level 8

Re: PCF Refresh Form

This is something that the embedded CanvasApp control does when calling ModelDrivenFormIntegration.RefreshForm

Interally inside cc_MscrmControls.Canvas.* it uses:

 window.Xrm.Page.data.refresh()

@HemantG - will this eventually be supported in custom PCF components? It seems unfair that the first party CC can do it but we can't! 😂

DianaBirkelbach
Level: Powered On

Re: PCF Refresh Form

 


@ScottDurow wrote:

This is something that the embedded CanvasApp control does when calling ModelDrivenFormIntegration.RefreshForm

Interally inside cc_MscrmControls.Canvas.* it uses:

 window.Xrm.Page.data.refresh()

@HemantG - will this eventually be supported in custom PCF components? It seems unfair that the first party CC can do it but we can't! 😂


Since Xrm.Page is deprecated, I suppose that won't be the way to do it.

Maybe if the control notifies the form about a change (even if not the current attribute was actually changed)? Maybe that could trigger a data refresh? 

NickDewitt
Level 8

Re: PCF Refresh Form

Thanks for the feedback everyone, in the end I just ended up displaying the data that I needed to update inside the control so that I didn't need to refresh the form at all.

On a side note, context.navigation.openForm({ }) actually wasn't too bad, although it did refresh the whole form with a little flicker, it didn't refresh the ribbon or side menu, so while not as nice as the formContext.data.refresh(), it was better than nothing.

I would still like to know the answer to @ScottDurow's question; Will this eventually be supported in custom PCF components? any chance on a comment @hemant?

On another side note, this is literally the most happy I have ever been while customising Dynamics/Powerapps, so keep up the great work!

cakhaing
Level: Powered On

Re: PCF Refresh Form

When PCF supports binding of complex data types, we probably don't need to 'Refresh' the form inside PCF. 

Ideally, a PCF component should update attributes of the host record via bound properties, instead of updating via WebAPI.

 

If you really need it, I would suggest to refresh the form outside PCF. For example,

1. Bind PCF to an attribute (could be a dummy attribute)

2. Update a record via WebAPI just like you are doing right now

3. Update the value of the bound property in PCF (that will trigger onChange event of the attribute)

4. On the Form customisation, add onChange event on the attribute and write JavaScript to execte formContext.data.refresh

 

@NickDewitt I've used above approach to refresh the subgrid and works well. 

 

@HemantG Will we be able to bind these complex data types (https://docs.microsoft.com/en-us/powerapps/developer/component-framework/manifest-schema-reference/p...) in PCF in the near future?

ScottDurow
Level 8

Re: PCF Refresh Form

This approach - whilst would work introduces some negative coupling between form JavaScript and the PCF component. A maker wouldn’t be able to just add a control to their form - they would also need to write JavaScript and know how the control works.
Highlighted
PowerApps Staff HemantG
PowerApps Staff

Re: PCF Refresh Form


@cakhaing wrote:

When PCF supports binding of complex data types, we probably don't need to 'Refresh' the form inside PCF. 

Ideally, a PCF component should update attributes of the host record via bound properties, instead of updating via WebAPI.

 

If you really need it, I would suggest to refresh the form outside PCF. For example,

1. Bind PCF to an attribute (could be a dummy attribute)

2. Update a record via WebAPI just like you are doing right now

3. Update the value of the bound property in PCF (that will trigger onChange event of the attribute)

4. On the Form customisation, add onChange event on the attribute and write JavaScript to execte formContext.data.refresh

 

@NickDewitt I've used above approach to refresh the subgrid and works well. 

 

@HemantG Will we be able to bind these complex data types (https://docs.microsoft.com/en-us/powerapps/developer/component-framework/manifest-schema-reference/p...) in PCF in the near future?


That is the best supported way to do it, thanks.  We are reviewing the complex data types - Lookup.Simple is the one which is priority for next semester. Other will be added in future releases. 

PowerApps Staff HemantG
PowerApps Staff

Re: PCF Refresh Form


@ScottDurow wrote:
This approach - whilst would work introduces some negative coupling between form JavaScript and the PCF component. A maker wouldn’t be able to just add a control to their form - they would also need to write JavaScript and know how the control works.

Ack the pain point here , we are working on the plan to address it more graceful and generic manner. We will make details available when ready.

 

thanks,

Hemant 

View solution in original post

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: 441 members 6,507 guests
Please welcome our newest community members: