//Automatic generation of end date
function EndDateGeneration() {
var NewDate = new Date(Xrm.Page.getAttribute( “new_startdate”).getValue());
if (NewDate.getMonth() < 3) {
DateYear = NewDate.getYear();
}
else if (NewDate.getMonth() > 2) {
}
if (DateYear % 4 == 0 && DateYear % 100 != 0) {
var Enddate = new Date(NewDate.setDate(NewDate.getDate() + 365));
}
else if (DateYear % 4 == 0 && DateYear % 100 == 0 && DateYear % 400 != 0) {
var Enddate = new Date(NewDate.setDate(NewDate.getDate() + 365))
}
else {
var Enddate = new Date(NewDate.setDate(NewDate.getDate() + 364));
}
Xrm.Page.getAttribute( “new_enddate”).setValue(Enddate);
Xrm.Page.getAttribute( “new_enddate”).setSubmitMode(“always” );
Xrm.Page.ui.controls.get( “new_enddate”).setDisabled(true );
}
SOURCE : JUST2CODE.IN
Subscribe to our YouTube channel : https://www.youtube.com/user/TheRussell2012