How to automatically set date field base on another date field

Greeting,

I want to automatically input the value into the Project End Date field base on date of Project Start Date field plus one year within the input screen. So how can i do it?

Regards,

Natha

  • 0

    Hi Natha,

    Here I understood that you want to set Project End Date as below.

    Project End Date = Project Start Date + 1 Year

    You can easily achieve the same by writing client side script in the OnChange script section of Project Start Date field. Script will read the value of Project Start Date and add the year part by 1 and finally setting the same in the Project End Date field. Here you also need to take care of User Date format of CRM user.

    You can refers the below forum link for your reference.

    community.sagecrm.com/.../populating-default-date-field-values.aspx

    community.sagecrm.com/.../5070.aspx

    Hope this helps!

    Sincerely,

    Dinesh

  • 0

    Hi Natha,

    Try this function and place it in the custom content area and call it in the On-change .

    *****custom content*****

    function increamentYear(){

    var d, m, y;

    //var userDateFormat = CRM.UserOption("NSet_UserDateFormat").toLowerCase();

    var userDateFormat = CurrentUser.user_prf;

    if (userDateFormat.match(/d?d[/.]m?m[/.]yyyy/))

    {

    d = 1;

    m = 2;

    y = 3;

    }

    else if (userDateFormat.match(/M?M[/.]d?d[/.]yyyy/))

    {

    d = 2;

    m = 1;

    y = 3;

    }

    else if (userDateFormat.match(/yyyy[/.]m?m[/.]d?d/))

    {

    d = 3;

    m = 2;

    y = 1;

    }

    quot_expiredelivery = $("#quot_expiredelivery").val(); //-------------> Here is the field where you read the date

    var dt = quot_expiredelivery.match(/(\d+)[/.](\d+)[/.](\d+)/);

    year = parseInt(dt[y]);

    year++;

    $("#quot_description").val(quot_expiredelivery.replace(dt[y],year)); //-------------------->> Here is the field where the date + 1 year appears

    }

    *****On-change******

    increamentYear()

    Good Luck,

    TJ.