Skip to main content

Notifications

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

  • Suggested answer
    Fabio Gadaleta Profile Picture
    20 on at
    RE: ExecutionContext.getFormContext returns null value

    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

  • Juanlor Profile Picture
    5 on at
    RE: ExecutionContext.getFormContext returns null value

    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.

  • Fabio Gadaleta Profile Picture
    20 on at
    RE: ExecutionContext.getFormContext returns null value

    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

  • Suggested answer
    Nya Profile Picture
    29,060 on at
    RE: ExecutionContext.getFormContext returns null value

    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;
    }

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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >

Product updates

Dynamics 365 release plans