Set Default value to 3 days from now

Henrik Jutterst
Tera Guru

On a Catalog Item, in a new date variable - is there a way to set Default Value to current date and add (for example) 3 days from now?

find_real_file.png

Above example sets current date. But how can I add 3 more days in the default value?

 

My goal is to add days dynamic based on Delivery time (delivery_time) in the default value.

 find_real_file.png

 

Lite this in portal:

find_real_file.png

1 ACCEPTED SOLUTION

asifnoor
Kilo Patron

You can mention under default value

javascript:var gdt=new GlideDateTime();gdt.addDays(3);gdt.getDate();

View solution in original post

6 REPLIES 6

Geetanjali Khy2
Mega Guru

Hey Henrik, 

 

You can refer the answer suggested by Asif.

In case if you need something dynamic, you can do something like this:

javascript:addDays(4);

With script include:

function addDays(numDays) {
	
	var gdt = new GlideDateTime();
	gdt.addDaysLocalTime(numDays);
	
	return gdt;
}

 

Please mark my answer as Correct/Helpful if it helps you to resolve your issue.

 

Thank You.

 

Regards,

Geetanjali Khyale

ServiceNow Developer

Hi and thanks for the reply.

I guess the problem is to access the value in [delivery_time] on the catalog item, when I'm on the variable... Do you know if that's possible?

But as you say.. Creating a Script Include that's taking the sys_id of the current catalog item and returning the delivery time might be a solution.

I'll check that out.