How to set a default date on record producer?

htank66
Kilo Contributor

Hi All,

I need help with making a Catalog Client Script to set a default date for a date field that will be four days out.

1 ACCEPTED SOLUTION

Allen Andreas
Administrator
Administrator

Hi,

If it's a Date field, you don't even need a client script. You can click the variable on the record producer and set the default value to be:

javascript: var gdt = new GlideDate(); gdt.addDays(4); gdt.getDisplayValue();

That will automatically set it to 4 days from today.

Please mark reply as Helpful/Correct. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

4 REPLIES 4

Allen Andreas
Administrator
Administrator

Hi,

If it's a Date field, you don't even need a client script. You can click the variable on the record producer and set the default value to be:

javascript: var gdt = new GlideDate(); gdt.addDays(4); gdt.getDisplayValue();

That will automatically set it to 4 days from today.

Please mark reply as Helpful/Correct. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Thank you so much! Is there anyway to make it business days though?

Good Morning,

I'll need to look and test something before I can give certain script. For future reference...you should ask for that initially in your question because you did not state that at all. For now, please mark my other reply as Helpful if it was.

Thanks


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Please reference this link with has correct answer script. Currently, I believe in it, it only adds 1 day, see the addDays line, but you can test it out. This would go in your default value section instead of what I gave:

https://community.servicenow.com/community?id=community_question&sys_id=c9cbcfa1db9cdbc01dcaf3231f96...

Please mark reply as Helpful/Correct. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!