cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Advocate II
Advocate II

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


@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
MVP

@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.

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! 😂

 


@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? 

Advocate II
Advocate II

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!

Advocate IV
Advocate IV

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?

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.


@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. 


@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
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Users online (3,655)