convert glide duration into seconds and add it to the glide date time filed?

Shantharao
Kilo Sage

How to convert glide duration filed into seconds and, this seconds to be add into glide date time filed

 

Thanks

1 ACCEPTED SOLUTION

Shantharao
Kilo Sage

I achieved with the below code

 

/**
-> dues date will be the time it got assigned and delivery_time
-> created custom after insert business rule as per the busimess need
-> Auto populating delivery time of catalog item in the generated RITMs due_date & expected delivery

-> ritmRec.cat_item.delivery_time is catalog item delivery time duration type filed populated in REQ & RITMs due date 
**/

var ritmRec = new GlideRecord("sc_req_item");
ritmRec.addQuery("request", current.getUniqueValue());
ritmRec.query();
while (ritmRec.next()) {
if (JSUtil.notNil(ritmRec.cat_item.delivery_time)) {
var deliveryTimeGlideDate = new GlideDateTime(ritmRec.cat_item.delivery_time);
var seconds = deliveryTimeGlideDate.getNumericValue() / 1000;
var openedGlideDate = new GlideDateTime(current.opened_at);
openedGlideDate.addSeconds(seconds);
ritmRec.due_date.setValue(openedGlideDate);
ritmRec.estimated_delivery.setValue(openedGlideDate);
ritmRec.update();
}
}

View solution in original post

1 REPLY 1

Shantharao
Kilo Sage

I achieved with the below code

 

/**
-> dues date will be the time it got assigned and delivery_time
-> created custom after insert business rule as per the busimess need
-> Auto populating delivery time of catalog item in the generated RITMs due_date & expected delivery

-> ritmRec.cat_item.delivery_time is catalog item delivery time duration type filed populated in REQ & RITMs due date 
**/

var ritmRec = new GlideRecord("sc_req_item");
ritmRec.addQuery("request", current.getUniqueValue());
ritmRec.query();
while (ritmRec.next()) {
if (JSUtil.notNil(ritmRec.cat_item.delivery_time)) {
var deliveryTimeGlideDate = new GlideDateTime(ritmRec.cat_item.delivery_time);
var seconds = deliveryTimeGlideDate.getNumericValue() / 1000;
var openedGlideDate = new GlideDateTime(current.opened_at);
openedGlideDate.addSeconds(seconds);
ritmRec.due_date.setValue(openedGlideDate);
ritmRec.estimated_delivery.setValue(openedGlideDate);
ritmRec.update();
}
}