Hi all,
I am attempting to create a contacts age in a custom calculated field of data type whole number.
So far I have:
1. written the following code.js:
function calculateAge(birthdate) {
var today = new Date();
var birthDate = new Date(birthdate);
var age = today.getFullYear() - birthDate.getFullYear();
var monthDiff = today.getMonth() - birthDate.getMonth();
if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {
age--;
}
return age;
}
2. Uploaded as a web resource
3. Added library to form that contains both fields (birthdate and age)
4. opened calculated field and in action i attemoted to put the following
calculateAge(birthdate)

but it says:
calculateAge function does not exist.
I would reaaly appreciate any help or advice please.
Many thanks
Mathu