web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

ExecutionContext.getFormContext returns null value

(1) ShareShare
ReportReport
Posted on by 20

Hi, from today, I encounter this problem when try to get the formContext from a nested editable grid. This, solution worked well till yesterday but today return a null value. 

This is my situation: I have put a onRecordSelect Method to try to block some columns in my grid. I have a grid and a nested grid from this one. The first one works without problem, the second, have the null value when get the formContext

pastedimage1636998786677v1.png

This is my method when the record select trigger.

pastedimage1636998950837v2.png

And this is how I pass the executionContext as first parameter

pastedimage1636999056070v3.png

Till Yesterday the solution works and now not.

Anyone have some tips or any workaround for this problem?

P.S. I'm sorry for my bad english

I have the same question (0)
  • Suggested answer
    Nya Profile Picture
    29,060 on at

    Hi,

    Would you please share the error log which can be downloaded in the bottom of the error message?

    Or you can try to add a code snippet something like the following into your JS before the getData:

    if (xxx == null) {
        alert('cancel');
        break;
    }

  • Fabio Gadaleta Profile Picture
    20 on at

    Hi Nya,

    the problem is the getFormContext method return null. The ExecutionContext (first parameter passed through the trigger event) isn't null. I can see all the attributes in the grid (about the entity) and all the value inserted.

    pastedimage1637053599783v1.png

    As I said before, till yesterday (in this case 2 days ago), this script worked well, but from today the script can't get the formContext from the ExecutionContext of the nested subgrid. 

    The ExecutionContext.getFormContext() of the page, works

    The ExecutionContext.getFormContext() of the main grid works

    The ExecutionContext.getFormContext() of the nested grid in main grid doesn't works.

    About reply the error, I've tried to simulate in debug cause i've bypass the error putting a null control (just a workaroud to let the user to work). this is the error:

    pastedimage1637053908327v2.png

    Thanks for the interested

  • Juanlor Profile Picture
    5 on at

    I have the same problem in a productive environment and I'm using a temporary ugly solution:

    var formContext = executionContext.getFormContext();
    if (!formContext) {
    formContext = Xrm.Page;
    }

    Regards.

  • Suggested answer
    Fabio Gadaleta Profile Picture
    20 on at

    Thanks Juanlor. This isn't the main form but the nested subgrid in an another subgrid. so Xrm.Page is referenced to the main page.

    By the way, the workaround I've found is this change:

    instead of

    "ExecutionContext.getFormContext().getData().getEntity().attributes.forEach(function (attr) { ... "

    where the getFormContext() return null, I've used:

    "ExecutionContext.getEventSource().attributes.forEach(function (attr) { ... "

    where i can do my logic with columns.

    thanks anyway

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 74

#3
Martin Dráb Profile Picture

Martin Dráb 64 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans