After I deployed CRM 2011 Rollup 13 I started receiving this error message True is undefined. It is also complaining about setAgeInHeader. After I Roll back to Rollup 12 it works. again. Any clue why? This is on the OnLoad Event
function calculateBMI(){
var height = Xrm.Page.data.entity.attributes.get('emc_height').getValue();
var weight = Xrm.Page.data.entity.attributes.get('emc_weight').getValue();
if (height === undefined || height ==null)
{
return;
}
if (weight === undefined || weight ==null)
{
return;
}
if(height == 0)
{
return;
}
if(weight == 0)
{
return;
}
var bmi = weight * 703 / (height * height);
//alert('bmi' + bmi);
var Bmi = Xrm.Page.data.entity.attributes.get("emc_bmi");
//alert('Bmi' + Bmi);
Bmi.setValue(bmi);
}
function setAgeInHeader() {
var birthday = Xrm.Page.data.entity.attributes.get('birthdate').getValue();
if (!birthday)
return;
var age = getAge(birthday);
var ageString = '';
if (age.years < 1 && age.months > 0)
ageString = age.months + ' months';
else if (age.years < 1 && age.months < 1 && age.days > 0)
ageString = age.days + ' days';
else
ageString = age.years;
document.getElementById("header_emc_age_d").childNodes[0].innerHTML = ageString;
}
function getAge(fromdate){
var today = new Date(),
fromdate = new Date(fromdate),
y = [today.getFullYear(), fromdate.getFullYear()],
ydiff = y[0] - y[1],
m = [today.getMonth(), fromdate.getMonth()],
mdiff = m[0] - m[1],
d = [today.getDate(), fromdate.getDate()],
ddiff = d[0] - d[1];
if(mdiff < 0 || (mdiff === 0 && ddiff < 0))
--ydiff;
if(mdiff < 0)
mdiff += 11;
if(ddiff < 0) {
fromdate.setMonth(m[1]+1, 0);
ddiff = fromdate.getDate() - d[1] + d[0];
--mdiff;
}
return {
years: ydiff,
months: mdiff,
days: ddiff
};
}
Thanks, Paul Nath