Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Answered

ReferenceError: formContext is not defined

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();
   }
}

  • joss17 Profile Picture
    joss17 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!

  • Verified answer
    Pradeep Rai Profile Picture
    Pradeep Rai 5,490 Super User 2024 Season 2 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
    joss17 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

  • Pradeep Rai Profile Picture
    Pradeep Rai 5,490 Super User 2024 Season 2 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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans