Skip to main content

Notifications

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Subgrid returns null

Posted on by

Hello,

I am trying to retrieve control of a subgrid that exists in our form. The trouble I am running into is that sometimes the subgrid returns null and sometimes it returns the object I want. If I do a hard refresh (ctrl+ F5) sometimes I am able to get control of the subgrid, which returns this object below. I am at a lost and would love input/advice.

pastedimage1645485068797v1.png

But in other cases, it returns null.

pastedimage1645485114538v2.png

 
Things that I have tried:
- Adding a setTimeout to recall the function as the subgrid may take time to load.
- addOnLoad to the function to be called only when subgrid is loaded. This doesn't work because I need to get control of the subgrid (which is null)
- Made the function asynchronous
- Tried using document.getElementByID. Still returns null.
- Removed the subgrid, published, and re-inserted it.
Code:  
function filterColoSubGrid(executionContext) {
    debugger;
    var formContext = executionContext.getFormContext();
    var primaryFacility = formContext.getAttribute("gssitsm_primaryfacility").getValue();
    var primaryFacilityID = null;
    var coloSubGridContext= formContext.getControl("ColoSubGrid");

   if(coloSubGridContext==null){
        setTimeout(function () {filterColoSubGrid(executionContext); }, 2000);
        return;

    }
  • Coolbeans Profile Picture
    Coolbeans on at
    RE: Subgrid returns null

    This is currently a known bug with the product group. You can file a ticket through Power Platform/Dynamics support and they should be able to advise you. A fix is to be released sometime in May 2022.

  • RE: Subgrid returns null

    Hi did you resolve this? I am having the same issue and have no idea why the subgrid always returns null

  • Coolbeans Profile Picture
    Coolbeans on at
    RE: Subgrid returns null

    Hey Nya,

    Thanks for your input. Unfortunately, I can't do that either because I'm not able to get control of that subgrid to refresh.

  • Suggested answer
    Nya Profile Picture
    Nya 29,056 on at
    RE: Subgrid returns null

    Hi,

    Have you tried to force the subgrid to refresh with the Javascript?

    coloSubGridContext.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

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans