Skip to main content

Notifications

Announcements

No record found.

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

TypeError: executionContext.getFormContext is not a function

Posted on by Microsoft Employee

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
  • RajarajanS Profile Picture
    RajarajanS 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

  • Denny Deng Profile Picture
    Denny Deng 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?

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee 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?

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans