Copy link to clipboard
Copied
Hey there, I have a given date which is a form field "Case.DATE(Date dd.MM.yyyy)", and need to check, if it's before or after the 14.09.2022.
Based on that, another form field should just be filled in with an "x".
Is that possible with a util function?
Also, is there a way to automatically subtract 3 days from that given date?
Thousand thanks in Advance!
1 Correct answer
Yes, both of these things are possible. You should convert the value of the form field to a Date object using the util.scand method (make sure it's not empty first, though!) and create another Date object for the threshold date, and then compare the two by using their getTime methods.
To subtract 3 days from a Date object you can use its setDate and getDate methods, like this:
var d = new Date(); // d is the current date
d.setDate(d.getDate()-3); // d is now the current date minus 3 days
Copy link to clipboard
Copied
Yes, both of these things are possible. You should convert the value of the form field to a Date object using the util.scand method (make sure it's not empty first, though!) and create another Date object for the threshold date, and then compare the two by using their getTime methods.
To subtract 3 days from a Date object you can use its setDate and getDate methods, like this:
var d = new Date(); // d is the current date
d.setDate(d.getDate()-3); // d is now the current date minus 3 days
Copy link to clipboard
Copied
Is this also possible, if the original field, on which the calculation is based, is empty?
I only could get it to work while manually filling in the field.
The Formfields on our PDFs are always emtpy and being filled while processed by the system.
Copy link to clipboard
Copied
When the field is empty don't perform the calculation.

