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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Unable to get property 'setVisible' of undefined or null reference...

(0) ShareShare
ReportReport
Posted on by 26

When I load a record in CRM 2016, I am getting an error, "Unable to get property 'setVisible' of undefined or null reference"  I hit F12 to go through the debugger, but it doesn't go through it at all...it just pops up with the same error everytime.  This code works just fine in another environment...any ideas why it wouldn't work in my Dev environment?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi,

    setVisible is undefined that means control is getting null in your code so that's why setVisible is undefined.

    Could you please share your code.

    In addition you can try to add setVisible line  inside settimeout so that control will get.

    Make sure don't forget to  do null and undefined check of control object before doing setVisible.

  • Suggested answer
    Akanksha Ranjan Profile Picture
    460 on at

    Hi,

    In your code check the below mentioned condition before taking an action.

    function test(){

    var checkValue = Xrm.Page.getAttribute("new_attribute").getValue();

    if (checkValue != null || checkValue != 'undefined' || checkValue !=''){

    rest of the code here

    }

    }

     


    Thanks 

    PS: Please mark the answer as verified if found helpful.

     

  • Suggested answer
    Hameed Hussain Profile Picture
    250 on at

    The reason is your control object is returning a null and you're appending the 'setVisible' to a null object.

    Example - var obj = Xrm.Page.getControl("control_name").setVisible(false);

    In this case, the part Xrm.Page.getControl("control_name") is returning a null, and hence the error.  The reason could be you have spelled the "control_name" incorrectly or that control doesn't exist anymore.

    What you have to do:

    if(Xrm.Page.getControl("control_name") != null)

    {

         Xrm.Page.getControl("control_name").setVisible(false);

    }

  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi,

    Javascript function on-load of the form has a control which is null or undefined (maybe because you haven't added the control to form or the name of the control is not correct).

    Please check the condition as follows.

    var control = Xrm.Page.getControl("controlName");
    if((control ! = null) && (control != undefined))
    {
     control.setVisible(true);
    }

    Hope this helps.

  • Mohsin Ali Profile Picture
    3,634 on at

    It mean you don't have placed the field that you want to setVisible true or false. Also, in your source code you need to add keyword debugger; and then press F12 to see the debug your source code. 

  • Verified answer
    USA80 Profile Picture
    26 on at

    The issue was because I had the same function name in another script that was on load. Once I changed one of the function name to something else, it loaded fine.

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    If you got an answer (even you answered it) please verify it.

  • USA80 Profile Picture
    26 on at

    I did already.  Does it not show that?

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    I don't want to argue. I closed the thread. Please close your threads in future. Just friendly advice.

  • USA80 Profile Picture
    26 on at

    oh, no worries.  I did verify the answer, just didn't close the thread.  Sorry, thanks for the heads up.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans