- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2024 05:26 AM
I am working for Record Producer (RP table is HR payroll case) for workday integration for HRSD
1. variable is What date/dates is this request for? and logic is If selected date is within 2 weeks of today's date and the choice is Vacation. Then display a pop-up message. Vacation requests must be at least 2 weeks in advance and will require additional approvals if you wish to proceed. felid type is Date and time.
2. variable is Exception Reason variable type is multiline text and logic is Display if If selected date is within 2 weeks of today's date and the choice is Vacation.
Can anyone help in code please
Thanks in adavnce
Charitha TS
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2024 05:48 AM - edited 09-10-2024 05:48 AM
@charitha ts You can create an onChange client script on both of your variables and use the following code.
// Get today's date
var today = new Date();
today.setHours(0, 0, 0, 0); // Set time to midnight for accurate comparison
// Parse the selected date
var selectedDate = new Date(newValue);
// Calculate two weeks from today's date
var twoWeeksLater = new Date(today);
twoWeeksLater.setDate(today.getDate() + 14);
// Check if selected date is within two weeks
if (selectedDate >= today && selectedDate <= twoWeeksLater) {
g_form.addInfoMessage('The selected date is within two weeks of today.');
} else {
g_form.clearMessages(); // Clear messages if no longer in the two-week window
}
Update the logic to show message/display exception reason field.
Hope this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2024 05:48 AM - edited 09-10-2024 05:48 AM
@charitha ts You can create an onChange client script on both of your variables and use the following code.
// Get today's date
var today = new Date();
today.setHours(0, 0, 0, 0); // Set time to midnight for accurate comparison
// Parse the selected date
var selectedDate = new Date(newValue);
// Calculate two weeks from today's date
var twoWeeksLater = new Date(today);
twoWeeksLater.setDate(today.getDate() + 14);
// Check if selected date is within two weeks
if (selectedDate >= today && selectedDate <= twoWeeksLater) {
g_form.addInfoMessage('The selected date is within two weeks of today.');
} else {
g_form.clearMessages(); // Clear messages if no longer in the two-week window
}
Update the logic to show message/display exception reason field.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2024 11:35 PM
First variable is working and second variable i will check and update you