web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Refresh section on field change

(0) ShareShare
ReportReport
Posted on by 27

Hi everyone,

 

I have a Power Automate Flow which updates a field on a custom dataverse table.

 

Could anyone share the JS syntax for automatically refreshing the section or page when that field changes? The reason I think I would need to refresh the section/page (the equivalent of clicking the Refresh button) is that I have an embedded canvas app in a section which needs to be updated when the field value changes.

 

My thinking is that I could place the field in a different section and run the JS function on the OnChange property against it.

best regards,

8015.picture1.png

I have the same question (0)
  • Verified answer
    Eiken Profile Picture
    on at

    Hi,

    Please use the following API:

    formContext.data.refresh(save).then(successCallback, errorCallback); 

    Please check the detail of this API.

    data.refresh (Client API reference) in model-driven apps - Power Apps | Microsoft Learn

    Now please refer to my steps.

    Edit the refreshpage function.

    function refreshpage(e){
        var formContext = e.getFormContext();
        formContext.data.refresh(true).then(function(result){
            alert('Refreshed!!')
        });
        }

    Add On change event to the selected field.(Now I choose ""Name")

    pastedimage1681263834961v1.png

    It works well.

    pastedimage1681263921683v2.png

  • Ami K Profile Picture
    27 on at

     Eiken  Thank you for the solution. Unfortunately, although the function triggers perfectly when changing a field inside the form, it seems a javascript function cannot trigger when a field has been changed by an external connector (in this case, Power Automate).

    There is a Power Automate flow which updates that field. In the video below, you can see the event triggers when I change the field directly inside the form, but the event does not trigger when a Power Automate Flow changes that field.

    I still find your solution very helpful though so I marked as Solved.

    If you happen to know if it is indeed possible to trigger the refresh, please let me know.

    [View:/cfs-file/__key/communityserver-discussions-components-files/761/recording.mp4:1440:1080]

  • Suggested answer
    maeneak Profile Picture
    7 on at
    I came up with a messy workaround using the OnChange event of the control. It triggers a save when the field is 'Dirty' which in turn triggers the flow, then run through a few nested setTimeout's and use showProgressIndicator to restrict/notify the user. I just picked a timeout value I was sure would cover the flow run time, but this is obviously not guaranteed for long flows.
     
    function SaveFormOnChangeIfDirty(primaryControl, fieldName, interval) {
        var formContext = primaryControl.getFormContext();
        var field = formContext.getAttribute(fieldName);
        if (field.getIsDirty() && field.getValue() != null) {
            formContext.data.save();
            Xrm.Utility.showProgressIndicator("Running flows and updating data...");
            setTimeout(function() {
                formContext.data.refresh();
                Xrm.Utility.closeProgressIndicator();
            }, interval);
        }
    }
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 76

#3
Martin Dráb Profile Picture

Martin Dráb 64 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans