CRM 2011 Javascript Date Add With Duration Based On Month, Year And Days


function DateAdd() {
    //Get today date
    var Today = new Date();

    //Get the date
    var DateSentOut = Xrm.Page.data.entity.attributes.get("DateFieldName").getValue();

    //Set based on days,months and years
    //Date.setMonth(month,day) / if year add with 12 month like that
    DateSentOut.setMonth(DateSentOut.getMonth() + 3); //Add 3 Months Duration

    //Set the field answer.
    Xrm.Page.data.entity.attributes.get("AnswerFieldName").setValue(DateSentOut);
}

0 comments: