Set a future date

RayRoulstone
Tera Expert

I have a date variable in a record producer. How would I set the default date to 10days in the future?

1 ACCEPTED SOLUTION

Tej2
Giga Expert

Hi Ray,

You would need to set the default date in the Record Producer Variable.

Key in this value in the default value field of the variable.

javascript:var dt = new GlideDateTime();dt.addDays(10);dt.getDisplayValue();

Refer to screenshot below:

find_real_file.png

You should see the field populated as below:

find_real_file.png

Please mark helpful, if it did indeed

Thanks,

Tej

View solution in original post

5 REPLIES 5

Tej2
Giga Expert

Hi Ray,

You would need to set the default date in the Record Producer Variable.

Key in this value in the default value field of the variable.

javascript:var dt = new GlideDateTime();dt.addDays(10);dt.getDisplayValue();

Refer to screenshot below:

find_real_file.png

You should see the field populated as below:

find_real_file.png

Please mark helpful, if it did indeed

Thanks,

Tej

Thanks, Tej. That's exactly what I was looking for and it works brilliantly.

RayRoulstone
Tera Expert

Hi Tej,

I'm wondering if you can help with a follow on question linked to this. Now I have set the date to something in the future I need to make this read only so the user completing the form cannot change the date.

Thanks.

Ray

Hi Ray,

You could make use of the Catalog UI policies to be able to do this. 

find_real_file.png

In the Catalog UI policy, you could include the conditions on when you would want the field to be read-only. 

Once the UI policy is created, you would have to create a UI policy action for that field. 

You could refer to this link: Create UI policy for Catalog Items

 

Please mark helpful, if it did indeed.

Thanks,

Tej