Set future date in a date type field

DiegoCamacho
Tera Contributor

Hi,

I have the following question, based on the selection of a field (If the "No" option is selected), a date type field must be enabled already set with a date 2 years ahead.

My difficulty lies precisely in this logic of making this date type field perform this two-year calculation based on the current date.

1 REPLY 1

Zach Koch
Giga Sage
Giga Sage

If you need this to happen on the Client side, you will need a client script with a GlideAjax call and a Script Include. If this can happen after saving, then you can do this in a Business rule with no need for a Script include.

You can take whatever date you need and use the GlideDateTime().addYears() method to add years to whatever your original date (after converting it to a GlideDateTime object) is.

Here is a link to the docs page as well as a screenshot of the relevant section

GlideDateTime docs 

ZachKoch_0-1718311793442.png

 

If this information helped resolve your issue, please remember to mark response correct and thumbs up to help future community members on this information, thanks!