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

Unable to get property 'getvalue' of undefined or null reference

(0) ShareShare
ReportReport
Posted on by 22

Getting the following error while trying to add JScript to a form to show/hide sections based on a type filed and owner. Any help is appreciated!

pastedimage1594226110193v1.png

// JavaScript source code
//Show/hide sections based on request type and owner
function showHideProductTestSections() {
 //get field value
 var RequestType = window.parent.Xrm.Page.data.entity.attributes.get("Request Type").getValue();
 var Owner = window.parent.Xrm.Page.data.entity.attributes.get("Owner").getValue(); {
  if ((RequestType = "R&D") && ((Owner = "Dr. Jason Galary") || (Owner = "Gus Flaherty") || (Owner = "Jayna DeMedeiros") || (Owner = "Dr. Chris Andreola") || (Owner = "Dr. Mihai Bancu") || (Owner = "Dr. Jennifer Frias") || (Owner = "Dr. Amanda Stubbs") || (Owner = "Rich Bellizzi") || (Owner = "Rich Rathiel") || (Owner = "Kevin McBarron") || (Owner = "Mason Wood") || (Owner = "John Doherty") || (Owner = "Melissa LaRochelle") || (Owner = "Brian Candido") || (Owner = "Rob Mulkern") || (Owner = "Paul Moses")
    //hide sections based on value
   )) {
   window.parent.Xrm.Page.ui.tabs.get("RequestDetails").section.get("ProductTest").setVisible(true);
   window.parent.Xrm.Page.ui.tabs.get("RequestDetails").section.get("RequestDetails_section_3").setVisible(true);
   window.parent.Xrm.Page.ui.tabs.get("RequestDetails").section.get("RequestDetails_section_4").setVisible(true);
   window.parent.Xrm.Page.ui.tabs.get("RequestDetails").section.get("RequestDetails_section_6").setVisible(true);
   window.parent.Xrm.Page.ui.tabs.get("Lab Details").section.get("LabDetails").setVisible(true);
   window.parent.Xrm.Page.ui.tabs.get("TestParameters&Results").section.get("Parameters").setVisible(true);
   window.parent.Xrm.Page.ui.tabs.get("TestParameters&Results").section.get("Results").setVisible(true);
   window.parent.Xrm.Page.ui.tabs.get("TestParameters&Results").section.get("AdditionalResults").setVisible(true);
   window.parent.Xrm.Page.ui.tabs.get("TestParameters&Results").section.get("TestParameters&Results_section_6").setVisible(true);
   window.parent.Xrm.Page.ui.tabs.get("ConclusionAttachements").section.get("Conclusion").setVisible(true);
   window.parent.Xrm.Page.ui.tabs.get("ConclusionAttachements").section.get("NotesAttachements").setVisible(true);
   // Display an alert box
   alert("R&D Request");
  } else if (RequestType != "R&D") {
   window.parent.Xrm.Page.ui.tabs.get("RequestDetails").section.get("ProductTest").setVisible(false);
   window.parent.Xrm.Page.ui.tabs.get("RequestDetails").section.get("RequestDetails_section_3").setVisible(false);
   window.parent.Xrm.Page.ui.tabs.get("RequestDetails").section.get("RequestDetails_section_4").setVisible(false);
   window.parent.Xrm.Page.ui.tabs.get("RequestDetails").section.get("RequestDetails_section_6").setVisible(false);
      window.parent.Xrm.Page.ui.tabs.get("Lab Details").section.get("LabDetails").setVisible(false);
   window.parent.Xrm.Page.ui.tabs.get("TestParameters&Results").section.get("Parameters").setVisible(false);
   window.parent.Xrm.Page.ui.tabs.get("TestParameters&Results").section.get("Results").setVisible(false);
   window.parent.Xrm.Page.ui.tabs.get("TestParameters&Results").section.get("AdditionalResults").setVisible(false);
   window.parent.Xrm.Page.ui.tabs.get("TestParameters&Results").section.get("TestParameters&Results_section_6").setVisible(false);
   window.parent.Xrm.Page.ui.tabs.get("ConclusionAttachements").section.get("Conclusion").setVisible(false);
   window.parent.Xrm.Page.ui.tabs.get("ConclusionAttachements").section.get("NotesAttachements").setVisible(false);
   alert("Non R&D Request");
  }
 }
}
I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Unable to get property 'getvalue' of undefined or null reference

    I would highly recommend to use F12 and debug to see where the script fails.

  • MParadise85 Profile Picture
    22 on at
    RE: Unable to get property 'getvalue' of undefined or null reference

    I hope everyone had a good weekend! I've made all the suggested updates and I'm still getting the following error. Help and suggestions very much appreciated. 

    pastedimage1594659171663v1.png

    // JavaScript source code
    //Show/hide sections based on request type and owner
    function showHideProductTestSections() {
    //get field value
    var RequestType = window.parent.Xrm.Page.data.entity.attributes.get("new_requesttype").getText();
    var Owner = window.parent.Xrm.Page.data.entity.attributes.get("ownerid").getValue();
    if ((RequestType == "R&D" ) && ((Owner[0].name == "Dr. Jason Galary") || (Owner[0].name == "Gus Flaherty") ||
    (Owner[0].name == "Jayna DeMedeiros") || (Owner[0].name == "Dr. Chris Andreola") ||
    (Owner[0].name == "Dr. Mihai Bancu") || (Owner[0].name == "Dr. Jennifer Frias") ||
    (Owner[0].name == "Dr. Amanda Stubbs") || (Owner[0].name == "Rich Bellizzi") ||
    (Owner[0].name == "Rich Rathiel") || (Owner[0].name == "Kevin McBarron") ||
    (Owner[0].name == "Mason Wood") || (Owner[0].name == "John Doherty") ||
    (Owner[0].name == "Melissa LaRochelle") || (Owner[0].name == "Brian Candido") || (Owner[0].name == "Rob Mulkern") ||
    (Owner[0].name == "Paul Moses")))
    //hide sections based on value
     {
    window.parent.Xrm.Page.ui.tabs.get("RequestDetails").section.get("RequestDetails_section_3").setVisible(true);
    window.parent.Xrm.Page.ui.tabs.get("RequestDetails").section.get("ProductTest").setVisible(true);
    window.parent.Xrm.Page.ui.tabs.get("RequestDetails").section.get("RequestDetails_section_4").setVisible(true);
    window.parent.Xrm.Page.ui.tabs.get("RequestDetails").section.get("RequestDetails_section_6").setVisible(true);
    window.parent.Xrm.Page.ui.tabs.get("LabDetails").section.get("LabDetails").setVisible(true);
    window.parent.Xrm.Page.ui.tabs.get("TestParametersResults").section.get("Parameters").setVisible(true);
    window.parent.Xrm.Page.ui.tabs.get("TestParametersResults").section.get("Results").setVisible(true);
    window.parent.Xrm.Page.ui.tabs.get("TestParametersResults").section.get("AdditionalResults").setVisible(true);
    window.parent.Xrm.Page.ui.tabs.get("TestParametersResults").section.get("TestParametersResults_section_6").setVisible(true);
    window.parent.Xrm.Page.ui.tabs.get("TestParametersResults").section.get("TestParametersResults_section_5").setVisible(true);
    window.parent.Xrm.Page.ui.tabs.get("TestParametersResults").section.get("TestParametersResults_section_3").setVisible(true);
    window.parent.Xrm.Page.ui.tabs.get("ConclusionAttachements").section.get("Conclusion").setVisible(true);
    window.parent.Xrm.Page.ui.tabs.get("ConclusionAttachements").section.get("NotesAttachements").setVisible(true);
    // Display an alert box
    alert("R&D Request");
    }
    else if (RequestType != "R&D") {
    window.parent.Xrm.Page.ui.tabs.get("RequestDetails").section.get("RequestDetails_section_3").setVisible(false);
    window.parent.Xrm.Page.ui.tabs.get("RequestDetails").section.get("ProductTest").setVisible(false);
    window.parent.Xrm.Page.ui.tabs.get("RequestDetails").section.get("RequestDetails_section_4").setVisible(false);
    window.parent.Xrm.Page.ui.tabs.get("RequestDetails").section.get("RequestDetails_section_6").setVisible(false);
    window.parent.Xrm.Page.ui.tabs.get("LabDetails").section.get("LabDetails").setVisible(false);
    window.parent.Xrm.Page.ui.tabs.get("TestParametersResults").section.get("Parameters").setVisible(false);
    window.parent.Xrm.Page.ui.tabs.get("TestParametersResults").section.get("Results").setVisible(false);
    window.parent.Xrm.Page.ui.tabs.get("TestParametersResults").section.get("AdditionalResults").setVisible(false);
    window.parent.Xrm.Page.ui.tabs.get("TestParametersResults").section.get("TestParametersResults_section_6").setVisible(false);
    window.parent.Xrm.Page.ui.tabs.get("TestParametersResults").section.get("TestParametersResults_section_5").setVisible(false);
    window.parent.Xrm.Page.ui.tabs.get("TestParametersResults").section.get("TestParametersResults_section_3").setVisible(false);
    window.parent.Xrm.Page.ui.tabs.get("ConclusionAttachements").section.get("Conclusion").setVisible(false);
    window.parent.Xrm.Page.ui.tabs.get("ConclusionAttachements").section.get("NotesAttachements").setVisible(false);
    }
    }
  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at
    RE: Unable to get property 'getvalue' of undefined or null reference

    Hi,

    Please find below updated code. I have update condition check with == instead of =. Also removed unneccessary curly braces. I have also update fullname with name. 

    // JavaScript source code
    
    //Show/hide sections based on request type and owner
    
    function showHideProductTestSections() {
    
    //get field value
    
    var RequestType = window.parent.Xrm.Page.data.entity.attributes.get("new_requesttype").getText();
    
    var Owner = window.parent.Xrm.Page.data.entity.attributes.get("ownerid").getValue();
    
    if ((RequestType == "R&D") && ((Owner[0].name == "Dr. Jason Galary") || (Owner[0].name == "Gus Flaherty") || 
    (Owner[0].name == "Jayna DeMedeiros") || (Owner[0].name == "Dr. Chris Andreola") || 
    (Owner[0].name == "Dr. Mihai Bancu") || (Owner[0].name == "Dr. Jennifer Frias") || 
    (Owner[0].name == "Dr. Amanda Stubbs") || (Owner[0].name == "Rich Bellizzi") || 
    (Owner[0].name == "Rich Rathiel") || (Owner[0].name == "Kevin McBarron") || 
    (Owner[0].name == "Mason Wood") || (Owner[0].name == "John Doherty") || 
    (Owner[0].name == "Melissa LaRochelle") || (Owner[0].name == "Brian Candido") || (Owner[0].name == "Rob Mulkern") || 
    (Owner[0].name == "Paul Moses")
    //hide sections based on value
    
    )) {
    
    window.parent.Xrm.Page.ui.tabs.get("Test Details").section.get("Product & Test").setVisible(true);
    
    window.parent.Xrm.Page.ui.tabs.get("Test Details").section.get("RequestDetails_section_3").setVisible(true);
    
    window.parent.Xrm.Page.ui.tabs.get("Test Details").section.get("RequestDetails_section_4").setVisible(true);
    
    window.parent.Xrm.Page.ui.tabs.get("Test Details").section.get("RequestDetails_section_6").setVisible(true);
    
    window.parent.Xrm.Page.ui.tabs.get("Lab Details").section.get("Lab Details").setVisible(true);
    
    window.parent.Xrm.Page.ui.tabs.get("Test Parameters & Results").section.get("Parameters").setVisible(true);
    
    window.parent.Xrm.Page.ui.tabs.get("Test Parameters & Results").section.get("Results").setVisible(true);
    
    window.parent.Xrm.Page.ui.tabs.get("Test Parameters & Results").section.get("Additional Results").setVisible(true);
    
    window.parent.Xrm.Page.ui.tabs.get("Test Parameters &Results").section.get("TestParameters&Results_section_6").setVisible(true);
    
    window.parent.Xrm.Page.ui.tabs.get("Conclusion, Notes & Attachements").section.get("Conclusion").setVisible(true);
    
    window.parent.Xrm.Page.ui.tabs.get("Conclusion, Notes & Attachements").section.get("Notes & Attachements").setVisible(true);
    
    // Display an alert box
    
    alert("R&D Request");
    
    } 
    else if (RequestType != "R&D") {
    
    window.parent.Xrm.Page.ui.tabs.get("Test Details").section.get("Product & Test").setVisible(false);
    
    window.parent.Xrm.Page.ui.tabs.get("Test Details").section.get("RequestDetails_section_3").setVisible(false);
    
    window.parent.Xrm.Page.ui.tabs.get("Test Details").section.get("RequestDetails_section_4").setVisible(false);
    
    window.parent.Xrm.Page.ui.tabs.get("Test Details").section.get("RequestDetails_section_6").setVisible(false);
    
    window.parent.Xrm.Page.ui.tabs.get("Lab Details").section.get("Lab Details").setVisible(false);
    
    window.parent.Xrm.Page.ui.tabs.get("Test Parameters & Results").section.get("Parameters").setVisible(false);
    
    window.parent.Xrm.Page.ui.tabs.get("Test Parameters & Results").section.get("Results").setVisible(false);
    
    window.parent.Xrm.Page.ui.tabs.get("Test Parameters & Results").section.get("Additional Results").setVisible(false);
    
    window.parent.Xrm.Page.ui.tabs.get("Test Parameters &Results").section.get("TestParameters&Results_section_6").setVisible(false);
    
    window.parent.Xrm.Page.ui.tabs.get("Conclusion, Notes & Attachements").section.get("Conclusion").setVisible(false);
    
    window.parent.Xrm.Page.ui.tabs.get("Conclusion, Notes & Attachements").section.get("Notes & Attachements").setVisible(false);
    
    }
    }

    Now only thing you should change in your code is Tab name and section name. I have highlighted the name in tab properties.

    CQ39.PNG

    If found helpful, Please mark my answer verified.

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Unable to get property 'getvalue' of undefined or null reference

    Hello,

    Here are few additional changes you should apply:

    1. If you want to use Display Value of optionset field and not int value of it use getText instead of getValue (that will return the whole number value and not the label) - docs.microsoft.com/.../gettext

    2. When you compare owner use name, not the fullname so comparison should look like Owner[0].name == "Dr. Jason Galary", not like Owner[0].fullname == "Dr. Jason Galary"

    3. Seems that for getting of Tabs and Sections you used labels but not names. You should use names - open carefully properties of each tab/section and replace with the name and not label.

    Good luck.

    Also my strong recommendation - master basics of JS troubleshooting - you will get the result much faster. I recorded the video where I demonstrated those basics - www.youtube.com/watch

  • MParadise85 Profile Picture
    22 on at
    RE: Unable to get property 'getvalue' of undefined or null reference

    Thank you Andrew, see below.

    // JavaScript source code

    //Show/hide sections based on request type and owner

    function showHideProductTestSections() {

    //get field value

    var RequestType = window.parent.Xrm.Page.data.entity.attributes.get("new_requesttype").getValue();

    var Owner = window.parent.Xrm.Page.data.entity.attributes.get("ownerid").getValue(); {

    if ((RequestType = "R&D") && ((Owner[0].fullname == "Dr. Jason Galary") || (Owner[0].fullname == "Gus Flaherty") || (Owner[0].fullname == "Jayna DeMedeiros") || (Owner[0].fullname == "Dr. Chris Andreola") || (Owner[0].fullname == "Dr. Mihai Bancu") || (Owner[0].fullname == "Dr. Jennifer Frias") || (Owner[0].fullname == "Dr. Amanda Stubbs") || (Owner[0].fullname == "Rich Bellizzi") || (Owner[0].fullname == "Rich Rathiel") || (Owner[0].fullname == "Kevin McBarron") || (Owner[0].fullname == "Mason Wood") || (Owner[0].fullname == "John Doherty") || (Owner[0].fullname == "Melissa LaRochelle") || (Owner[0].fullname == "Brian Candido") || (Owner[0].fullname == "Rob Mulkern") || (Owner[0].fullname == "Paul Moses")

    //hide sections based on value

    )) {

    window.parent.Xrm.Page.ui.tabs.get("Test Details").section.get("Product & Test").setVisible(true);

    window.parent.Xrm.Page.ui.tabs.get("Test Details").section.get("RequestDetails_section_3").setVisible(true);

    window.parent.Xrm.Page.ui.tabs.get("Test Details").section.get("RequestDetails_section_4").setVisible(true);

    window.parent.Xrm.Page.ui.tabs.get("Test Details").section.get("RequestDetails_section_6").setVisible(true);

    window.parent.Xrm.Page.ui.tabs.get("Lab Details").section.get("Lab Details").setVisible(true);

    window.parent.Xrm.Page.ui.tabs.get("Test Parameters & Results").section.get("Parameters").setVisible(true);

    window.parent.Xrm.Page.ui.tabs.get("Test Parameters & Results").section.get("Results").setVisible(true);

    window.parent.Xrm.Page.ui.tabs.get("Test Parameters & Results").section.get("Additional Results").setVisible(true);

    window.parent.Xrm.Page.ui.tabs.get("Test Parameters &Results").section.get("TestParameters&Results_section_6").setVisible(true);

    window.parent.Xrm.Page.ui.tabs.get("Conclusion, Notes & Attachements").section.get("Conclusion").setVisible(true);

    window.parent.Xrm.Page.ui.tabs.get("Conclusion, Notes & Attachements").section.get("Notes & Attachements").setVisible(true);

    // Display an alert box

    alert("R&D Request");

    } else if (RequestType != "R&D") {

    window.parent.Xrm.Page.ui.tabs.get("Test Details").section.get("Product & Test").setVisible(false);

    window.parent.Xrm.Page.ui.tabs.get("Test Details").section.get("RequestDetails_section_3").setVisible(false);

    window.parent.Xrm.Page.ui.tabs.get("Test Details").section.get("RequestDetails_section_4").setVisible(false);

    window.parent.Xrm.Page.ui.tabs.get("Test Details").section.get("RequestDetails_section_6").setVisible(false);

    window.parent.Xrm.Page.ui.tabs.get("Lab Details").section.get("Lab Details").setVisible(false);

    window.parent.Xrm.Page.ui.tabs.get("Test Parameters & Results").section.get("Parameters").setVisible(false);

    window.parent.Xrm.Page.ui.tabs.get("Test Parameters & Results").section.get("Results").setVisible(false);

    window.parent.Xrm.Page.ui.tabs.get("Test Parameters & Results").section.get("Additional Results").setVisible(false);

    window.parent.Xrm.Page.ui.tabs.get("Test Parameters &Results").section.get("TestParameters&Results_section_6").setVisible(false);

    window.parent.Xrm.Page.ui.tabs.get("Conclusion, Notes & Attachements").section.get("Conclusion").setVisible(false);

    window.parent.Xrm.Page.ui.tabs.get("Conclusion, Notes & Attachements").section.get("Notes & Attachements").setVisible(false);

    }

    }

    }

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Unable to get property 'getvalue' of undefined or null reference

    Can you please provide you current version of the code?

  • MParadise85 Profile Picture
    22 on at
    RE: Unable to get property 'getvalue' of undefined or null reference

    Thank you Andrew, I made the suggested changes and the error fixed. Now I can load/save the record with the event enabled on the form but its not hiding the tabs/sections as expected. Any thoughts? Thank you again for taking the time to review and for your suggestions, I don't write a lot of Java and really appreciate the help!  

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Unable to get property 'getvalue' of undefined or null reference

    Hello,

    Your code doesn't work because you use Labels instead of schema names for your attributes. Here is an example:

    window.parent.Xrm.Page.data.entity.attributes.get("Owner").getValue(); - incorrect

    window.parent.Xrm.Page.data.entity.attributes.get("ownerid").getValue(); - correct

    Also following line:

    Owner = "Dr. Jason Galary"

    will always fail because - lookup is an array of objects so in order to make your code correctly here is correct comparison:

    Also comparison in JS is ==, not =.

    Owner[0].name == "Dr. Jason Galary"

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 258

#2
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 167

#3
Tom_Gioielli Profile Picture

Tom_Gioielli 116 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans