Indranil Sarkar
Indranil Sarkar

Reputation: 1280

Getting property value is undefined or null error for JavaScript call in Dynamics CRM 2011

Just started with Javasript + Dynamics 2011 today and got stuck at the beginning itself. I've been trying simple steps as follow 1. Change the value on radio button 2. Call a function from Javascript, which will set two field enabled and disabled

Code is as follows

function navenabled()
{

    var navdata = Xrm.Page.getAttribute("new_currentnavclient").getValue;

    if (navdata == true)
    {
        Xrm.Page.getControl(“new_noofusers”).setDisabled(true);
        Xrm.Page.getControl(“new_navversion”).setDisabled(true);
    }
    else
    {
        Xrm.Page.getControl(“new_noofusers”).setDisabled(false);
                Xrm.Page.getControl(“new_navversion”).setDisabled(false);
    }

}

I'm getting the following error, when changing the value on 'Current Nav Client' field

enter image description here

Also see the steps that I have performed for JavaScript call

enter image description here

Can someone please tell where I'm doing wrong.

Upvotes: 2

Views: 6682

Answers (2)

Martin
Martin

Reputation: 56

What you can try to do is using the document.getElementById ("fieldname").checked property. This value is allways accurate.

Upvotes: 0

Guido Preite
Guido Preite

Reputation: 15128

First problem is with this line:

var navdata = Xrm.Page.getAttribute("new_currentnavclient").getValue;

getValue is a method, so the right way is getValue()

var navdata = Xrm.Page.getAttribute("new_currentnavclient").getValue();

The second problem is with all the getControl lines, you are using smart quotes

“ ”

Instead you need to use simple quotation marks, so your code will be:

function navenabled()
{

    var navdata = Xrm.Page.getAttribute("new_currentnavclient").getValue();

    if (navdata == true)
    {
        Xrm.Page.getControl("new_noofusers").setDisabled(true);
        Xrm.Page.getControl("new_navversion").setDisabled(true);
    }
    else
    {
        Xrm.Page.getControl("new_noofusers").setDisabled(false);
        Xrm.Page.getControl("new_navversion").setDisabled(false);
    }

}

Upvotes: 3

Related Questions