Hi All
I’m bit new to JScript, trying to calculate year, month and date from DOB field, I picked up the link from below, and tried it, could any one suggest if this is correct as I’m experiencing error
community.dynamics.com/.../get-month-day-year-from-a-date-field-in-crm-using-javascript
osplitDateandTime = {
splitDateofBirth : function(exeecutionContext){
//debugger;
var formcontext = executionContext.getFormcontext();
if(formcontext.getAttribute("new_dateofbirth")){
var datefieldValue = formcontext.getAttribute('new_dateofbirth').getValue();
if(dateFieldValue !==null){
var yearDOB = dateFieldValue.getFullYear().toString();
var monthDOB = (datefieldValue.getMonth()+ 1).toString();
var dayDOB = dateFieldValue.getDate().toString();
FormContext.getAttribute("dcuk_year").setValue("yearDOB");
FormContext.getAttribute("dcuk_monthdob").setValue(("0"+ monthDOB).slice(-2));
FormContext.getAttribute("dcuk_datedob").setValue(("0"+ dayDOB).slice(-2));
} else {
FormContext.getAttribute("dcuk_year").setValue(null);
FormContext.getAttribute("dcuk_year").setValue(null);
FormContext.getAttribute("dcuk_year").setValue(null);
}
}
}
};
Thanks
Jag
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156