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

Announcements

No record found.

News and Announcements icon
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
  • Suggested answer
    Community Member Profile Picture
    on at

    Hi,

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

  • Denny Deng Profile Picture
    Microsoft Employee on at

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

  • RajarajanS Profile Picture
    Microsoft Employee on at

    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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Daniyal Khaleel Profile Picture

Daniyal Khaleel 58 Most Valuable Professional

#2
Travis South Profile Picture

Travis South 37

#3
ParthPatel249 Profile Picture

ParthPatel249 19

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans