|
| 1 | +📘 README — Auto Update Resolution SLA on Related Tasks |
| 2 | +Business Rule Details |
| 3 | + |
| 4 | +Name: Auto Update Resolution SLA Reference |
| 5 | +Table: task_sla |
| 6 | +Execution: After Insert |
| 7 | +Filter Condition: SLA Definition target must be Resolution |
| 8 | +Condition: Runs only when the associated task is an Incident or a Catalog Task |
| 9 | +(current.task.sys_class_name == 'incident' || current.task.sys_class_name == 'sc_task') |
| 10 | + |
| 11 | +Purpose |
| 12 | + |
| 13 | +This Business Rule is designed to automatically update the related Incident and Task records with the Resolution SLA reference when a new Task SLA record is created. |
| 14 | +It helps provide direct visibility of SLA details from the Incident or Task form without navigating to the task_sla table. |
| 15 | + |
| 16 | +How It Works |
| 17 | + |
| 18 | +A new Resolution SLA is created for a task. |
| 19 | + |
| 20 | +This rule triggers after the Task SLA record is inserted. |
| 21 | + |
| 22 | +It checks if the related task is an Incident or a Catalog Task. |
| 23 | + |
| 24 | +It updates the custom SLA reference fields on both the Incident and the Task. |
| 25 | + |
| 26 | +Prerequisites |
| 27 | + |
| 28 | +You must create the following fields before using this rule: |
| 29 | + |
| 30 | +Field: u_resolution_sla (On Incident table) |
| 31 | +Type: Reference to task_sla |
| 32 | + |
| 33 | +Field: u_task_resolution_sla (On Task table) |
| 34 | +Type: Reference to task_sla |
| 35 | + |
| 36 | +Testing Steps |
| 37 | + |
| 38 | +• Create a new Incident and associate a Resolution SLA with it. |
| 39 | +• Allow the SLA to start (so it creates a task_sla entry). |
| 40 | +• Open the Incident and related Task. |
| 41 | +• You should see the Resolution SLA reference auto-populated in both. |
| 42 | + |
| 43 | +Script Used |
| 44 | +(function executeRule(current, previous /*null when async*/ ) { |
| 45 | + |
| 46 | + var inc = new GlideRecord('incident'); |
| 47 | + inc.get(current.task); |
| 48 | + |
| 49 | + inc.u_resolution_sla = current.sys_id; |
| 50 | + inc.update(); |
| 51 | + |
| 52 | + var tsk = new GlideRecord('task'); |
| 53 | + tsk.get(current.task); |
| 54 | + |
| 55 | + tsk.u_task_resolution_sla = current.sys_id; |
| 56 | + tsk.update(); |
| 57 | + |
| 58 | +})(current, previous); |
| 59 | + |
| 60 | +Result |
| 61 | + |
| 62 | +This automation ensures the SLA is visible and reportable on both Incident and Task records with no manual updates. |
| 63 | +It improves SLA tracking, reporting, and overall usability. |
0 commit comments