Add 6 months to a variable date (on change) and display result in another field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2018 12:14 AM
Hi ,
We have a two variables in a catalog item start and end date if the start date is changed then the changed date should add 6 months and display the output in End date variable.
Does anyone have done idea on this?
Done with the catalog client script using the below script this returns an error while the date format is dd-mm-yyy and dd/mm/yyyy
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('DateTimeAjaxFunctions');// DateTimeAjaxFunctions is a script include
ga.addParam('sysparm_name','nowDateTime');
ga.getXML(callback);
var retdt = g_form.getValue('end_date');
function callback(response){
var now = response.responseXML.documentElement.getAttribute("answer");
ga.addParam('sysparm_name','addMonths');
ga.addParam('startDate',newValue);
ga.addParam('monthsToAdd',6);
ga.getXML(callback1);
}
function callback1(response)
{
var sixMonthsFromNow = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('end_date',sixMonthsFromNow);
}
}
- Labels:
-
Team Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2018 02:59 AM
All the things are working fine as expected .There is a problem only when we change the format date got changed to 'DD-MM-YYYY' and DD/MM/YYYY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2019 12:12 AM
Hi Rao,
Any update on this?
Can you mark my answer as correct, helpful if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps users to learn from your thread. Thanks in advance.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader