
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2022 04:10 AM
Hello,
There is requirement where I need to auto populate the date after 90 days in a catalog item using catalog client script.
A field A (Drop down) has an option 90 days. When user selects this option then field B (Date field) should be visible on the form, and it should auto populate the date after 90 days comparing the current date.
Tried the below script which is not populating the correct date and the output is 2001-12-30,
This needs to be implemented in priority.
Thanks in advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2022 08:28 AM - edited 12-01-2022 08:51 AM
Hey @Community Alums
Please try the below script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 90) {
//alert(newValue);
var current_date = new Date();
//alert('Current Date'+current_date);
current_date.setDate(current_date.getDate() + 90);
var added_date = formatDate(current_date, g_user_date_time_format);
var getAddedDate = added_date.split(' ');
//alert('Output Date '+getAddedDate[0]);
g_form.setValue('output_date', getAddedDate[0]+'');
}
}
Mark this as Helpful / Accept the Solution if this clears your issue

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2022 09:22 AM
Hello Gautham,
The solution was helpful. Many thanks 🙂