In scoped application development, How to convert String value to date object so that it is compared and manipulated, to add number of days on ui page script ..

mamataj
Kilo Contributor

In scoped application development, How to manipulate date field value to add number of days .

Tried Using below code in Ui action, to add number of days to   start date   which is not working .

  var temp_date=this.getParameter('start_date');

  var s_date= new GlideDateTime();

  s_date.setValue(temp_date);

  var end_date=   new GlideDateTime();

  end_date.setValue(temp_date);

  gs.addInfoMessage('start date',s_date);

  var days=g_form.getValue('number_of_days');

  end_date.addDaysLocalTime(days);

  g_form.setValue('wo_end_date',temp_date);

We want to add number of days to start date to calculate end date .Kindly suggest some solution .

1 ACCEPTED SOLUTION

Hi Mamatha,



GlideDateTime is not available on Client Side, it is only available on the Server Side.


So what you can do is make your End_Date_Field readonly, provide the number of days in Number_of_days, Save.



Make one Before BR and pass the values there-->


var _noofDays = parseInt('current.getValue('number_of_days');


var _start = current.getValue('start_date_field');


var _end = new GlideDateTime(_start);


_end.addDaysLocalTime(_noofDays);


current.setValue('end_date_field',_end);


View solution in original post

5 REPLIES 5

Hi Mamatha,



If that answers your query would you be kind enough to mark my answer Correct and close the thread.