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 :
Customer experience | Sales, Customer Insights,...
Suggested answer

getFormContext is not a function

(0) ShareShare
ReportReport
Posted on by 30

Hi,

I am facing some issues customizing javascript on crm 2016. Basically i need to raise an event on change of a custom field on lead form.

Here is my code:

var context = {

loadFormContext: function (executionContext) {
debugger;
formContext = executionContext.getFormContext();
formContext.getAttribute("new_comune").addOnChangeEvent(this.onChangeComune);
},
onChangeComune: function (executionContext) {
var formContext = executionContext.getFormContext();

//DoSomething

}

}

I registered my functions on load events and change event on the lead form, flagging "pass the execution context as first parameter".

I am able to get in both functions debugging and i can see the executionContext object, it contains the global context but when i try to get the form context an error is handled "executionContext.getFormContext()is not a function".

I'm so confused, any suggestions?

I have the same question (0)
  • Suggested answer
    Guido Preite Profile Picture
    54,084 Moderator on at
    RE: getFormContext is not a function

    in crm 2016 you need to use Xrm namespace (like Xrm.Page.getAttribute)

    formContext is available starting from Dynamics 365 v9

  • erhan.keskin Profile Picture
    on at
    RE: getFormContext is not a function

    Hi,

    The Client API object model for model-driven apps (formContext) is introduced when the model-driven apps came to the stage. It is not used in Dynamics CRM 2016.

    docs.microsoft.com/.../understand-clientapi-object-model

    docs.microsoft.com/.../clientapi-form-context

    You need to use Xrm.Page object model.

    https://community.dynamics.com/365/b/d365demystified/posts/understanding-xrm-page-object-model

    Regards,

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

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans