- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2023 03:18 PM
Can anyone help me with the script for an action where the number of days can be added to the date.
Input: Date, No of days
Output: Date
Script needs to: add Date + No of days and return date
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2023 01:21 AM
@Shilpa Mannoni1 Here is the custom action for you which takes two parameters Date and number of days and add the days to date and returns the updated date.
Here is the script for run script.
(function execute(inputs, outputs) {
// ... code ...
var someDate = new GlideDate();
someDate.setValue(inputs.date);
someDate.addDaysUTC(inputs.days);
outputs.new_date = someDate;
})(inputs, outputs);
I am also attaching the update set which contains this Action.
Please mark this answer correct and helpful if it addresses your requirement.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2023 01:21 AM
@Shilpa Mannoni1 Here is the custom action for you which takes two parameters Date and number of days and add the days to date and returns the updated date.
Here is the script for run script.
(function execute(inputs, outputs) {
// ... code ...
var someDate = new GlideDate();
someDate.setValue(inputs.date);
someDate.addDaysUTC(inputs.days);
outputs.new_date = someDate;
})(inputs, outputs);
I am also attaching the update set which contains this Action.
Please mark this answer correct and helpful if it addresses your requirement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2023 02:13 PM
Thank you so much @Sandeep Rajput . This worked perfectly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2023 03:35 PM
Catalog Client Scripts
Need By Date Plus 14 Days From Today
OnChange
Variable Name: general_need_by_date
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var today_dateStr = formatDate(new Date(),g_user_date_format);
var todayNum = getDateFromFormat(today_dateStr,g_user_date_format);
var fourteen_days_from_today = new Date();
fourteen_days_from_today.setDate(fourteen_days_from_today.getDate()+14);
var fourteen_days_from_todayStr = formatDate(fourteen_days_from_today,g_user_date_format);
var fourteen_daysNum = getDateFromFormat(fourteen_days_from_todayStr,g_user_date_format);
var newValueNum = getDateFromFormat(newValue,g_user_date_format);
//alert ('todayNum: ' + todayNum);
//alert ('14_days_from_today: ' + fourteen_days_from_today);
//alert ('14_daysNum: ' + fourteen_daysNum);
//alert ('newValueNum: ' + newValueNum);
if(newValueNum < todayNum || newValueNum < fourteen_daysNum) {
g_form.addErrorMessage('"Need by date" must be at least 14 days from today: ' + fourteen_days_from_todayStr);
// alert('14 days from today is ' + fourteen_days_from_todayStr);
g_form.clearValue('general_need_by_date');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2023 03:37 PM
That script is for the Catalog Item (not for Flow Designer)