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 :
Microsoft Dynamics CRM (Archived)

Issue while getting the GridContext on save event of a editable subgrid

(0) ShareShare
ReportReport
Posted on by

Hey
I'm facing the problem to get gridContext on save event of a editable subgrid. I need to get the data from editable subgrid and do some operations on the form but while getting the grid from gridContext it shows the error message called "gridContext.getGrid is not a function".

JavaScriptCode.png

I'm referring the below msdn link to get gridContext and grid data.
https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/clientapi-grid-context
https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/grids/gridrowdata

Can anyone please advise on this? It is very urgent.
Any help would be much appreciated.





 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Jalak,

    Try with this  with getControl("GridName")

      var myRows= formContext.getControl("gridName").getGrid().getRows();


  • Community Member Profile Picture
    on at

    Hey Goutam,

    I've tried above code also. Its not working for me. It shows error message like "formContext.getControl is not a function". Please refer below image.

    JavaScriptCode1.png

  • Denis Bespalov Profile Picture
    on at

    executionContext.getFormContext() in this scope will give you only "GridRowContext".

    For example you can access each attribute in a row like this:

    executionContext.getFormContext().data.entity.attributes.getByName("selectedRowAttributeName");

    I don't know if this is a bug, but I also wasn't  able to get the whole GridContext for this event.

  • kunalks2003 Profile Picture
    315 on at

    the issue is with the documentation . you can not get grid object form grid row.

  • kunalks2003 Profile Picture
    315 on at

    Can you please tell what you are trying to achieve. the the form Context  is of Grid Row and you can not access the grid from it .

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    I can see in the second line of screenshot retrieving  formContext but you gave the name gridcontext.

            function onEmployeeDetailsSave(executionContext) {
                var formContext = executionContext.getFormContext(); // get the form Context
                var gridContext = formContext.getControl("Contacts"); // get the grid context provinding subgrid name
                var myRows = gridContext.getGrid().getRows();
            }


  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi jalak,

    Check the below link. The grid context depends upon from where you are calling the javascript.

    docs.microsoft.com/.../clientapi-grid-context

    Once you get the gridcontex, you can get the rows as well -

    docs.microsoft.com/.../gridrowdata

    Hope this helps.

  • Community Member Profile Picture
    on at

    Having the same issue with the "onChange" event.

    This is an issue with Microsoft's documentation here: https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/clientapi-grid-context

    That link gives an example to get "gridContext".

    This link gives an example to "getGrid" from "gridContext": https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/clientapi/reference/grids/gridcontrol/getgrid

    However, the "gridContext" from "onChange" does not have a "getGrid" function.

    @Microsoft - please update your documentation to be more clear.

  • BSD517 Profile Picture
    on at

    Did you ever find a resolution for this?  I'm having the same problem.  

  • kunalks2003 Profile Picture
    315 on at

    the context depends on the control/form that is firing the event .

    if the event is onload /onchange/onsave of the form you will get the form context , if the event is from a editable grid onchange you get the row context . please explain what you want to achieve and we may be able to suggest better solution.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ZS-27011425-0 Profile Picture

ZS-27011425-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans