In this post, we will show how to register a function that runs on the loading of a subgrid in Dynamics 365.
Consider the Contacts subgrid, of which the control is called “Contacts”:

We can write code to get the control below using the formContext:
var subgrid = formContext.getControl(“Contacts”);
Now, in order to add a function, we use the addOnLoad method. Let’s add a function on the fly here:
subgrid.addOnLoad(function() { console.log(“Grid onload function has run”); });
Now, when we refresh the subgrid, the function will run:
subgrid.refresh();
We see:
Grid onload function has run


Keep learning. Keep building.
Explore AI, agents & Microsoft technology.
I share practical ideas, tutorials, and videos about AI, AI agents, Microsoft technologies, and the Power Platform.
Subscribe on YouTube →Carl de Souza Enterprise Architect at Microsoft · AI Technology Expert