Fetch SLA Duration Value Dynamically

lakshmidurga
Tera Expert

Hi All,

I have a duration field(u_sla) on Catalog Task form which will change dynamically depending on Catalog Item.

I am trying to set Duration value on SLA defination depending on duration value of Task form.

I have written a business rule on contract_sla table as:

var ctask = new GlideRecord('sc_task');

ctask.addQuery("sys_id",current.task);

ctask.query();

while(ctask.next())

{    

current.duration = ctask.u_sla;

ctask.update();

}

Please help me in getting this achieved.

Thanks and Regards

Lakshmi Vallisetty

4 REPLIES 4

Rohini Peraval1
Tera Contributor

Hi,


I think you can write a BR on catalog task table.


Glide contract_sla table and update the field duration with the value of u_sla of current task.



var csla= new GlideRecord('contract_sla');


csla.addQuery("name",provide name of the sla which you want to update the duration field);


csla.query();


if(csla.next())


{  


csla.duration = current.u_sla;


csla.update();


}



Thanks,


Hi Rohini,



Thanks for your reply.


While defining SLA I gave SLA duration as 1 days and my business rule should over ride the value.


But the duration value is getting set to 00 00:00:00


Dominik Simunek
Tera Guru

Hi,



I believe that what you are trying to achieve cannot be done by updating SLA Definition or at least it is too risky. SLA Definition is really a definition for several Task SLAs and if you update it, it can affect other Task SLAs as well. If you had catalog task with SLA 4 hours and afterwards another catalog task with SLA 2 hours and you updated SLA Definition with the second one, the first task would get during recalculation also those 2 hours that are newly in SLA definition (I guess so from my knowledge of the scripts but I did not test it).



You would need to create Relative Duration with a script taking dynamically the duration from the catalog item and calculating Breach Time using DurationCalculator. The only drawback is that relative duration SLAs does not support pause duration by default. However this is a way how we achieved similar requirement - getting exact SLA duration dynamically from a task or related records.



Best regards,


Dominik


Hi Dominik,



Got your point.



Thank you so much for your suggestion