Sync fields from task SLA to HR Case

Drishti
Tera Guru

Hello Community,

 

There is field named "Actual Time Elapsed" on Task SLA . I have to copy the value to new field created on HR Case form. 
I have created after insert/update BR on task sla table . But the thing is this is getting update only one time. 
I want both the fields values to be same.

Below is the script used in BR :

var hr_case = new GlideRecord("sn_hr_core_case");
if(hr_case.get(current.task)) {
hr_case.setValue("u_sla_actual_elapsed_time", current.duration);
hr_case.autoSysFields(false);
hr_case.setWorkflow(false);
hr_case.update();
}

 

And condition is :

Actual Time Elapsed changes 

Please guide what else I can do get both field values same.

Thanks in advance!

4 REPLIES 4

pavani_paluri
Giga Guru
Giga Guru

Hi @Drishti ,

 

Change your rule so that it runs every time the SLA is updated (not just when "Actual Time Elapsed" changes). Inside your script, check if the value has really changed — and update the HR Case if it has.

 

Duration on the Task SLA record does not continuously change like a stopwatch. It updates periodically via the SLA Engine, which runs on a schedule and in response to some SLA events. Therefore, your Business Rule only triggers when that specific field changes, and even then, only when the GlideRecord is saved with that change.

 

Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Pavani P

Ankur Bawiskar
Tera Patron
Tera Patron

@Drishti 

the field value doesn't change often but via a scheduled job which runs periodically and once changed your BR should run and update the field on HR table.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Two questions here :
1) What will be the condition to run this schedule job keeping in mind we have users from all over globe.

2) Will running this schedule job will not impact system performance ? As "Actual Time Elapsed" field on Task SLA is getting updated every second and if we run schedule job every second , will it not hamper system performance

@Drishti 

it's controlled at platform level and you should not touch those.

Don't make it run every second as it will lead to instance performance issue.

check this link for better explanation

How is the Elapsed time on the SLA updated in SN? Scheduled jobs, BRs, Script Includes? 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader