how to set due date based on date variable on catalog item?

Nic Omaha
Tera Guru

I have a date variable on a request item ( start date of new hire ). I would like the due date of the item to be updated when this field is populated. Any ideas on scripting or how I could accomplish this? I basically want this item complete by the time they start.

 

screenshot.JPG

4 REPLIES 4

Subhajit1
Giga Guru

Hi Nicholas,


If you want to have the REQ completed before the new Joinee joins, you can set the Start Date value as the Due Date value. Or am i missing any requirement of yours here. I suppose, the Start Date is the Date when the new User joins.



Write this script on the sc_req_item table:-



var daysStr = current.cat_item.delivery_time.getDisplayValue();


var days = daysStr.split(' ')[0];


current.due_date.setValue(gs.daysAgo(-1 * days));



Thanks,


Subhajit


harikrish_v
Mega Guru

Hi Nicholas,



What I understand is, you want to populate the due_date field based on the start_date field in which case you can use the below script in a before update business rule:-



var gdt = current.start_date.getGlideObject();


current.due_date=gdt.addDays(30); //30 days to complete Newjoinees onboarding



Hope this helps



Thanks & Regards,


Hari