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

Announcements

News and Announcements icon
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,086 Moderator on at

    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
    2,253 on at

    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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Hamza H Profile Picture

Hamza H 142 Super User 2026 Season 1

#2
Nagaraju_Matta Profile Picture

Nagaraju_Matta 128

#3
11manish Profile Picture

11manish 121

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans