- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2017 11:29 PM
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 .
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2017 05:51 AM
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2017 02:52 AM
Hi Mamata,
I have one question-: from where are you passing the values to temp_date?
var s_date= new GlideDateTime(); ==> This will set the current Date to s_date
s_date.setValue(temp_date);
var end_date= new GlideDateTime(); ==> This will set the current Date to end_date
end_date.setValue(temp_date);
gs.addInfoMessage('start date',s_date);
var days=g_form.getValue('number_of_days'); ==> This will return a string
end_date.addDaysLocalTime(days); ==> addDaysLocalTime() this function takes integer parameter but you are passing a string
g_form.setValue('wo_end_date',temp_date);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2017 05:17 AM
Thanks Nitish for your inputs, We need to fetch the value of date time field "start date " on current form .
Putting the value in temp_date as below:
var temp_date = g_form.getValue('start_date') ;
I tried with parseInt() , it didn't work .
We want to fetch Start date value and calculate end date, adding number of days to start date .Please suggest .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2017 05:51 AM
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2017 09:32 PM
Thank you for your time nitish, It worked successfully .
