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,...
Answered

ReferenceError: formContext is not defined

(0) ShareShare
ReportReport
Posted on by 15

I have this error when I want to add a record to the form of my dynamics 365 and this is what I have in the script

function VisibleRiskLevelField(executionContext) {
    var formContext = executionContext.getFormContext();
    if (formContext.getAttribute("axn_shephaseii").getValue() != null ) {
        formContext.getControl("axn_risklevel").setVisible(false);
        formContext.getAttribute("axn_risklevel").setRequiredLevel("none");
    }else {
         DisabledField();
   }
}

I have the same question (0)
  • Pradeep Rai Profile Picture
    5,489 Moderator on at
    RE: ReferenceError: formContext is not defined

    HI Joss,

    Please check below highlighted in form properties.

    pastedimage1638296284406v1.png

    For e.g. if VisibleRiskLevelField this function called on save of any entity then in On Save event of form the above highlighted checkbox should be checked.

    Thanks,
    Pradeep Rai.

    Please mark this as VERIFIED if it helps

  • joss17 Profile Picture
    15 on at
    RE: ReferenceError: formContext is not defined

    hi pradeed thank you for the response but already did it and does not work

    40146.PNG

  • Verified answer
    Pradeep Rai Profile Picture
    5,489 Moderator on at
    RE: ReferenceError: formContext is not defined

    Hi,

    Code looks good.

    just wanted know, is there any other javascript function called on same entity?

    Thanks.

  • joss17 Profile Picture
    15 on at
    RE: ReferenceError: formContext is not defined

    yes, the issue was in another funtion in my script on the same entity, thanks for the help!

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 159

#2
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 152

#3
Tom_Gioielli Profile Picture

Tom_Gioielli 134 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans