How to set system date properties(Target Start & Target finish) dynamically?

Hello Team,

I am trying to set the project template Target start and target finish property dynamically(date_start_target & date_start_due).

I am able to set date in field using following code.

Picture 1

//Getting today's date
var Todaysdate = new Date();

//Getting date in dd/MM/yyy format
var Currentdate = Todaysdate.getDate() + "/"
+ (Todaysdate.getMonth()+1) + "/"
+ Todaysdate.getFullYear();

//alert(Currentdate);

var newdate = new Date(Todaysdate);

//Setting Next day date
newdate.setDate(newdate.getDate() + 1);

//Getting date in dd/MM/yyy format
var NextDate = newdate.getDate() + "/"
+ (newdate.getMonth()+1) + "/"
+ newdate.getFullYear();
//alert(NextDate);

//Setting Project Target Start and Target Finish property with new values.
window.handleItemChange("date_start_target",Currentdate);
window.handleItemChange("date_due_target",NextDate);

On click of saving project it give following error

Picture 2

I am not getting which format is required.

Can any one please help me out?

  • Hi Tushar,

    I've looked at some existing project data to determine the proper format of a date property within Innovator. It would appear that we store a date/time value which looks like yyyy-mm-dd (Time). Here is a screenshot showing what the data looks like in SQL.

    Please try modifying your method to format the dates to this format.

    AJ

  • 0 オフライン in reply to AJ Sebastian

    Hi AJ,

    Thank you for your response in short time.

    Yes you are right AJ, aras store date time in yyyy-mm-dd HH:MM:SS this format. I was using dd/MM/yyyy and in that if date or month is less than 10 than it was using single digit i.e. d/M/yyyy. But now I modified my code and just using date yyyy/MM/dd format and its working.

    Here is the working code 

    var Currentdate = Todaysdate.getFullYear() + "-"
    + ((Todaysdate.getMonth()+1) < 10 ? ("0" + (Todaysdate.getMonth()+1)): (Todaysdate.getMonth()+1)) + "-"
    + (Todaysdate.getDate() < 10 ? ("0" + Todaysdate.getDate()) : Todaysdate.getDate());

    With this we can set date field dynamically.

    Once again thank you.