Skip to main content

Notifications

Announcements

No record found.

Service | Customer Service, Contact Center, Fie...
Suggested answer

subgrid : setCurrentView not working

Posted on by 111

Hi experts,

I'm using below function on  onload to set view of subgrid

But I'm getting this error : cannot read property 'getViewSelector' of null .

In view selector I already select all view.

Dynamics Version 9.1 online

function SetSubGridBasedOnCountry(executionContext) {

    var ContactsIFollow = {
        entityType: 1039, // SavedQuery
        id: "*******************",
        name: "uk form"
    }
    // Get the gridContext
    var formContext = executionContext.getFormContext();
    var gridContext = formContext.getControl("orderlineIteam");

    // Set the view using ContactsIFollow
    if (gridContext == null) {
    setTimeout(function() {
      SetSubGridBasedOnCountry(executionContext);
    }, 2000);
    return;
  } else {
  debugger;
  gridContext.getViewSelector().setCurrentView(ContactsIFollow);
  }
   
}

Kindly help to fix this or with some other workaround to set subgrid dynamically.

  • Ahtesham Profile Picture
    Ahtesham 111 on at
    RE: subgrid : setCurrentView not working

    Hi Andrew

    Imy code is working fine  in UCI  but not in legacy

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: subgrid : setCurrentView not working

    Everything looks find here. Try to replace line

    if (gridContext == null) {

    with line

    if (gridContext == null || !gridContext.getViewSelector) {

  • Ahtesham Profile Picture
    Ahtesham 111 on at
    RE: subgrid : setCurrentView not working

    Hi PFB SS

    pastedimage1585581684809v1.pngpastedimage1585581763116v2.png

  • a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: subgrid : setCurrentView not working

    Hello,

    Can you please provide following screenshots:

    1. Grid configuration (specifically I'm interested in grid name and view settings.

    2. How the grid looks like on the form.

  • Ahtesham Profile Picture
    Ahtesham 111 on at
    RE: subgrid : setCurrentView not working

    Log file:

    TypeError: Cannot read property 'getViewSelector' of null

       at Mscrm.FormControls.ClientApi.XrmTurboFormControlSubGrid.getViewSelector (

       at SetSubGridBasedOnCountry (

       at eval (eval at RunHandlerInternal (, <anonymous>:1:1)

       at RunHandlerInternal (

       at RunHandlers (

       at OnScriptTagLoaded (

       at

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,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans