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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Suggested Answer

Refresh a subgrid until a field has a certain value

(1) ShareShare
ReportReport
Posted on by 39

Hi all,
What do you recommend to auto-refresh a subgrid every 10 seconds by stopping the refresh as soon as a form field has a certain value?

(Both the form and the field are populated by external processes).

I initially tried with

Xrm.Utility.openEntityForm (formContext.data.entity.getEntityName (), formContext.data.entity.getId ());

but this refreshes the entire form, I would rather just refresh the subgrid to avoid flickering the page every 10 seconds

Thank you in advance!

I have the same question (0)
  • Suggested answer
    Yuri ji Profile Picture
    on at

    Hi,

    You can try adding “console.log(fieldValue)” to the code.

    Check the type of the value returned by "getValue()" on the console and change the condition in "if()".

  • usersm365 Profile Picture
    39 on at

    Thanks Yuri, with this code the subgrid refreshes every few seconds.
    If I manually try to change the "Import status" = "Completed" field, it stops refreshing.

    However, the "Import status" field is set to "Completed" by external processes (serever side).

    So the problem is that the subgrid does not stop refreshing because, until a refresh of the form is also done, it will not be able to read the actual value of the field but only the one shown in the form.

  • Suggested answer
    Yuri ji Profile Picture
    on at

    Hi,

    Please try the following code:

    function refreshSubgrid(executionContext) {
        var formContext = executionContext.getFormContext();
        var fieldValue = formContext.getAttribute("fieldLogicName").getValue(); 
        var subgrid = formContext.ui.controls.get("Subgrid_new_1");
        subgrid.refresh();
        var timer = setInterval(refreshSubgrid,10000,executionContext);
        if(fieldValue == “test”){
            clearInterval(timer);
        }
    }
    

  • usersm365 Profile Picture
    39 on at

    Thanks Andrew, 
    Solved how to update the subgrid, two problems remain:
    1) how to automatically update the subgrid every 10 seconds
    2) how to stop this auto-update as soon as the "Import status" field of the form assumes the value "Completed".

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    You can refresh a particular subgrid using the following code:

    //getting formContext

    formContext.getControl("subgrid id here").refresh();

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

News and Announcements

Season of Giving Solutions is Here!

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 > Service | Customer Service, Contact Center, Field Service, Guides

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 20 Super User 2025 Season 2

#2
TAHER Mehdi Profile Picture

TAHER Mehdi 14

#3
LightningStrikes Profile Picture

LightningStrikes 9

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans