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
I AM SPENDING MORE TIME THESE DAYS CREATING YOUTUBE VIDEOS TO HELP PEOPLE LEARN THE MICROSOFT POWER PLATFORM.
IF YOU WOULD LIKE TO SEE HOW I BUILD APPS, OR FIND SOMETHING USEFUL READING MY BLOG, I WOULD REALLY APPRECIATE YOU SUBSCRIBING TO MY YOUTUBE CHANNEL.
THANK YOU, AND LET'S KEEP LEARNING TOGETHER.
CARL