cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Valentinm2
Frequent Visitor

Refresh Form Page after Save

Hi,

I am working on a model-driven form. On the form I have a section that has a canvas app component. Whenever I change data on the form, I want the canvas app component to immediately update so that I don't have to press refresh on the command bar. Is it possible to write a js script that automatically refreshes the section or entire form on save?

1 ACCEPTED SOLUTION

Accepted Solutions

@Valentinm2, try this function to reload the full page:

 

function refreshPage(){
   Xrm.Utility.openEntityForm(Xrm.Page.data.entity.getEntityName(), 
                              Xrm.Page.data.entity.getId());
}

 

View solution in original post

5 REPLIES 5
AhmedSalih
Super User
Super User

Hello, @Valentinm2, You can create a Javascript web-resource with a function that's called on your Save Event.

 

Try something like this: (Using formContext.data.refresh(save) >> I set it to false to not save as the script will run on the save event)

function RefreshOnSave(executionContext) {

var formContext = executionContext.getFormContext();

formContext.data.refresh(false)

}

 

 

Regards,

Ahmed

If my reply helped you, please give a 👍. And if it has solved your issue, please consider a 👍 & Accepting it as the Solution to help other members of the community find it more.

My Blog: www.powerplatformplace.com

Hi Ahmed,

Thank you for the suggestion. Unfortunately, this did not resolve my issue. It seems to just refresh the data and not reload the form page.

 

Regards,

Valentin

@Valentinm2, try this function to reload the full page:

 

function refreshPage(){
   Xrm.Utility.openEntityForm(Xrm.Page.data.entity.getEntityName(), 
                              Xrm.Page.data.entity.getId());
}

 

@AhmedSalih Wow this worked like a charm, thank you so much!

Also an fyi for people using this solution in the future, methods in the Xrm.Utility namespace are being depreciated, so use Xrm.Navigation.openForm instead 🙂

@Valentinm2 , thank you! Here is the Full Function:

function refreshPage() {
    var formContext = executionContext.getFormContext();
    Xrm.Navigation.openForm(formContext.data.entity.getEntityName(),
        formContext.data.entity.getId());
}

 

Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (4,757)