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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Javascript TypeError: Cannot read properties of null (reading 'getValue')

(0) ShareShare
ReportReport
Posted on by

Dear All,

I am new to CRM and trying to develop a functionality to show or hide 'MultiSelect choice' field based on the value from other field. Since there is a limitiation to achieve this using CRM business rule, I tried using JS to achieve this functionality. But I am facing below error when trying to do this using JS. I have checked all the word spellings and everything is correct.

TypeError: Cannot read properties of null (reading 'getValue')

Please find my below JS code. Is it possible to advise what needs to be corrected please?

function HideorShowAccessibilityAdjustments(executionContext)

{
var formContext = executionContext.getFormContext();
if (formContext.getAttribute("mntr_areanyreasonableadjustmentsrequired").getValue()!=0) {
formContext.getAttribute("mntr_AccessibilityAdjustments").setVisible(true);
formContext.getAttribute("mntr_NonAccessibilityAdjustments").setVisible(true);
}
else if (formContext.getAttribute("mntr_Areanyreasonableadjustmentsrequired").getValue()!=1) {
formContext.getAttribute("mntr_AccessibilityAdjustments").setVisible(false);
formContext.getAttribute("mntr_NonAccessibilityAdjustments").setVisible(false);
}
}

Thank You,

Gowtham

I have the same question (0)
  • Verified answer
    Guido Preite Profile Picture
    54,086 Moderator on at

    that error happens when the field you are referring to is not added to the form or doesn't exist.

    in the code you posted check the field "mntr_areanyreasonableadjustmentsrequired"

    pay attention that when you refer to fields inside javascript they are lowercase, so "mntr_AccessibilityAdjustments" should be "mntr_accessibilityadjustments" and "mntr_NonAccessibilityAdjustments" should be "mntr_nonaccessibilityadjustments"

    hope it helps

  • Gowtham89 Profile Picture
    on at

    Hi Guido,

    Thanks for the response, Yes that did resolve the initial issue. But now I am facing the actual issue described below

    TypeError: formContext.getAttribute(...).setVisible is not a function

    In the JS code I am trying to show and hide 'Multi-Select' option field in CRM. Do I need to use a different function to make it work.

    Thank You,

    Gowtham

  • Verified answer
    Guido Preite Profile Picture
    54,086 Moderator on at

    setVisible is a sub method of a getControl, so your code you will need to write

    formContext.getControl("mntr_accessibilityadjustments").setVisible(true);

    formContext.getControl("mntr_nonaccessibilityadjustments").setVisible(true);

  • Gowtham89 Profile Picture
    on at

    Fantastic..Thanks Guido..You saved my day!!

    It works perfectly after I made the suggested changes. Thanks a lot.

    Thank You,

    Gowtham

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 180 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 123

#3
CU11031447-0 Profile Picture

CU11031447-0 100

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans