Please wait, loading...

 

AUTO GENERATE END DATE USING JAVASCRIPT IN MSCRM 2011 , 2013

February 14, 2014
//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) {
        DateYear = NewDate.getYear() + 1;
    }
    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

https://i0.wp.com/microsoftdynamics.in/wp-content/uploads/2020/04/Microsoftdynamics365.png?fit=640%2C651
Microsoft Dynamics Community Profile

Learn more