Add 4 business days to date variable on a catalog item

Jeff316
Kilo Guru

Any solutions I could find on the internet have not worked.

I only get strange behavior and have to delete the variable and create again.

We have a date field on a catalog item.

The default date should be 4 business days in the future.

If anyone is currently doing this, please help.

We only use the portal UI.

Thanks.

 

1 ACCEPTED SOLUTION

did you try replacing

edt.getDate();

with

edt.getDisplayValue();

View solution in original post

19 REPLIES 19

Use onLoad Client script with GlideAjax or did you try in default value?

Use the below script in defualt value on variable form

javascript:var gdt =  new GlideDateTime();
	var dc = new DurationCalculator();
	dc.setSchedule('08fcd0830a0a0b2600079f56b1adb9ae'); // Schedule sys_id
	 dc.setStartDateTime(gdt);
	  dc.calcDuration(4*9*3600); // 8-5 Schedule  so 9 Hrs
	
var edt= new GlideDateTime(dc.getEndDateTime())
edt.getDate();

Ok. I was just saying I can try that. Stand by. Fingers Crossed.

Ok dvp,

I'm getting a value returned to the Date field. But the format is bad, so I can't tell what date its returned.

03-02-0172

The same thing happens if I just use 

javascript:addDays(4);

 in the default field. I needed to use 

javascript:var d = new GlideDateTime(); d.setValue(gs.daysAgo(-5)); d.getDisplayValue();

so the date format would display correctly.

Can I manipulate your javascript in a similar way so the date is formatted correctly?

did you try replacing

edt.getDate();

with

edt.getDisplayValue();