Reputation: 1280
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
Also see the steps that I have performed for JavaScript call
Can someone please tell where I'm doing wrong.
Upvotes: 2
Views: 6682
Reputation: 56
What you can try to do is using the document.getElementById ("fieldname").checked property. This value is allways accurate.
Upvotes: 0
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