Ui Policy based on 2 dates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2022 07:18 AM
Hi
I wish to create a Ui Policy on a catalog item based on the current date and time and the leaver date of a user.
If the leave date is within 21days of the current date and time I wish a variable to get updated to true, if the leave date is over 21 days of the current date, the check box should remain false
Can anyone assist with script help
I did try doing it as shown below, by trying to add 21 days to the current date and then stating if the date21 is less than the end date, then set to true, but I am getting a client script error. I have found this to be done to the var datenow = gs.nowDateTime(); entry
function onCondition() {
var datenow = gs.nowDateTime();
var enddate = g_form.getValue('end_of_employment');
var datenow21 = datenow.addDays(21);
if(datenow <enddate){
g_form.setValue('less_than_3_weeks',true);
}
}
Many Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2022 07:30 AM
I think you have the test backwards and the wrong variable, if I understand correctly you want to know if the enddate is 21 days or less from today, that would be (enddate < datenow21), but you have (datenow < enddate).
Aoife