Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archive)
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?

  • erhan.keskin Profile Picture
    2,247 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,

  • Suggested answer
    Guido Preite Profile Picture
    54,057 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

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

Community Spotlight of the Month

Kudos to Mohamed Amine Mahmoudi!

Blog subscriptions now enabled!

Follow your favorite blogs

TechTalk: How Dataverse and Microsoft Fabric powers ...

Explore the latest advancements in data export and integration within ...

Leaderboard > Microsoft Dynamics CRM (Archive)

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans