AnsweredAssumed Answered

Error converting java.lang.Double output value 'NaN' for parameter age1

Question asked by diji.ng522351 on Jan 14, 2017
Latest reply on Jan 18, 2017 by Srinivas Chandrakanth Vangari

Hi All,

 

I'm trying to use a javascript in Mapping component to count the age of an employee.

However I'm getting this error.

" [Function: Scripting]: Error converting java.lang.Double output value 'NaN' for parameter age1.; Caused by: java.lang.NumberFormatException"

 

My input is dob(Date/Time) format.

 

Below is the javascript:

 

function calculateAge (birthDate, otherDate) {
birthDate = new Date(birthDate);
otherDate = new Date(otherDate);

var years = (otherDate.getFullYear() - birthDate.getFullYear());

if (otherDate.getMonth() < birthDate.getMonth() ||
otherDate.getMonth() == birthDate.getMonth() && otherDate.getDate() < birthDate.getDate()) {
years--;
}

return years;
}

var dateObj = new Date();
var year = dateObj.getFullYear();
firstdate = "1/1/"+ year;

age1 = calculateAge(dob, firstdate); // Format: MM/DD/YYYY

 

The output should be age of the employee and I tried to set from the profile to 'character' or 'number' but I am still getting this error. Please advise me on this issue.

 

Thank you.

 

Regards,

DiJi

Outcomes