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

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Suggested Answer

TypeError: executionContext.getFormContext is not a function

(0) ShareShare
ReportReport
Posted on by

Good day

Please could you help with the below error i keep getting:

I have the following function set up:

function CanUserUpdateField(executionContext, field) {
var formContext = executionContext.getFormContext();
if (formContext.getAttribute(field).getUserPrivilege().canUpdate && formContext.getAttribute(field).getIsDirty()) {
formContext.getAttribute(field).setSubmitMode("always");
} else {
formContext.getAttribute(field).setSubmitMode("never");
}
}
 
I keep getting the below error:
TypeError: executionContext.getFormContext is not a function
at CanUserUpdateField
please can someone advise what i am doing wrong or if there is something I am missing.
Thanks
I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at
    RE: TypeError: executionContext.getFormContext is not a function

    Hi,

    On your form, when you attached this function, did you check "Pass Execution Context" checkbox?

  • Denny Deng Profile Picture
    on at
    RE: TypeError: executionContext.getFormContext is not a function

    have you register CanUserUpdateField function in the form onload\onsave event and check the pass execution context option?

  • RajarajanS Profile Picture
    on at
    RE: TypeError: executionContext.getFormContext is not a function

    Hi partner,

    Kindly let me know if you are trying this from the click of a ribbon button or through a js on the form.

    If you are calling this function from a click of a button, then please follow the articles:

    [View:https://community.dynamics.com/crm/b/crminogic/posts/java-script-execution-context-provides-form-values-on-web-as-well-as-uci-in-dynamics-365-v9-0:750:50]

    [View:https://community.dynamics.com/365/f/dynamics-365-general-forum/305714/js-code-error-on-ui-client-but-not-on-web-client:750:50]

    [View:https://stackoverflow.com/questions/48202316/how-to-get-formcontext-in-ribbon-command-of-dynamics-365-9-0:750:50]

    If you are doing it through the form as a onChange Event, make sure you have passed the execution context to the function as shown below:

    pastedimage1570093751725v4.png

    Hope this helps.

    Thanks and Regards, 

    Raj

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 > Service | Customer Service, Contact Center, Field Service, Guides

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 60 Super User 2025 Season 2

#2
Siv Sagar Profile Picture

Siv Sagar 52 Super User 2025 Season 2

#3
Daniyal Khaleel Profile Picture

Daniyal Khaleel 36 Most Valuable Professional

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans