How can we convert the value of "Duration" field in SLA to hours

Aswathy3
Tera Expert

Hi All,

 

We have a requirement to create two custom fields in task_sla table record.

-> First field - Duration in hours ( We need to get the value of this field as the hours format of the "SLA Definition duration" field value. eg:- if duration is 2 days, then value of this field needs should be reflected as 24 hours)

-> Second Field - 5X VSL - (We need to get the value of this field as the multiplication of "Duration in hours" field *5. eg:- if "Duration in hours" is 24 then 5X VSL should be reflected as 120 hours.)

 

Can anyone please help me on this ASAP?

 

Thanks in advance.

Regards

Aswathy

9 REPLIES 9

Hi, testing in a PDI background window with an updated version of the code I supplied previously IE dot.walking to sla duration.
var gdt = new GlideDateTime(current.sla.duration);

I find that the results are correct\as expected. What exactly is the issue you have?

Hi Tony,

 

I have tried with the same code in BR and also the custom field created for storing "Duration in hours" tried with "Integer type" and "Duration" type.

Then I tried to raise new ticket and new SLA record got added to "task_sla" table but the value of "Duration in Hours" field is showing as blank.

Thanks

Aswathy

 

Hi, perhaps you could share xml of your BR and a task_sla record so that your configuration and custom fields are clear.

chetanb
Tera Guru

Hello @Aswathy3 ,

 

You can create 2 custom table in task_sla table and provide relevant details and use it in desired table as per your requirement.

Next, create after business rule to population on sla_definition

 

// duration from SLA definition (in seconds
var slaDuration = current.sla_definition.getSLADuration();

// Convert to hours
var durationInHours = Math.round(slaDuration / (60 * 60));

// Set values of custom fields
current.u_duration_in_hours = durationInHours;
current.u_five_x_vsl = durationInHours * 5;

// Update the record
current.update();

 

If my answer solves your query kindly mark as correct and helpful.

 

Regards,

CB

Hi Chetan,

The value of "Duration" actually we are looking the SLA definition duration and directly the value is not getting in TASK SLA form.

How can we get that data using script to get the duration in hours and 5X.

 

Thanks

Aswathy