- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2022 01:05 PM
I have a requirement for a variable to display month and year. However, there is no OOB method for this. I have two options, and i want to know how feasible this is and how do i do it. the options are;
- Block out all dates except the last day of the month in calender or
- Throw an error message if any other day but the last day of the month is selected.
Any help is appreciated.
Thanks
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2022 12:24 PM
Thanks for your response. When i try your code, it sets the date as below.
What could be the issue here?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2022 04:58 PM
Sorry, my bad. The problem is with the date format. I'm using yyyy-MM-dd. Updated to take user's date format.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '' || oldValue == newValue) {
return;
}
var curDate = getDateFromFormat(newValue, g_user_date_format);
curDate = new Date(curDate);
var lastDay = new Date(curDate.getFullYear(), curDate.getMonth() + 1, 0);
var dateFormat = g_user_date_format;
dateFormat = dateFormat.replace('yyyy', lastDay.getFullYear());
dateFormat = dateFormat.replace('MM', zeroPad((lastDay.getMonth() + 1)));
dateFormat = dateFormat.replace('dd', zeroPad(lastDay.getDate()));
if (newValue != lastDay) {
g_form.setValue('last_day_of_month', dateFormat);
}
function zeroPad(d) {
return ('00' + d).slice(-2);
}
}
Execution result using MM-dd-yyyy date format.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2022 10:26 AM
I need help similar to this.
This is for a date variable on an sc_cat_item form.
The requirement is that the date selected must be in the future compared to the current date.
If the future date selected is not the first day of the month, it sets to the first day of the following month.
(Just like how the Last day of month works above).
Examples:
1) If current date is 06/16/2022 and the date selected is 06/17/2022, then the date should autocorrect to 07/01/2022.
2) If current date is 06/16/2022 and the date selected is 12/02/2022, then the date should autocorrect to 01/01/2023.
Any help greatly appreciated.