Skip to content

Commit 5a0e77c

Browse files
authored
Update script.js
1 parent 00436aa commit 5a0e77c

File tree

1 file changed

+21
-27
lines changed
  • Client-Side Components/Client Scripts/validate Interaction if it is an FCR(First Call Resolution)

1 file changed

+21
-27
lines changed
Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,23 @@
1-
// Business Rule: Set Resolution SLA on Related Tasks
2-
// Table: task_sla
3-
// When: After Insert
1+
//Client Script to validate an Interaction record is resolved with out any related record created.
2+
function onSubmit() {
3+
var relatedTask = g_form.getValue('u_boolean_no_related_task');
4+
var state = g_form.getValue('state');
5+
var type = g_form.getValue('type');
6+
var workNotes = g_form.getValue('work_notes'); // Get the value of work notes
47

5-
// PURPOSE:
6-
// When a new Task SLA is created for Resolution SLA, update the related records.
8+
// Clear previous field messages
9+
g_form.clearMessages();
710

8-
// CONDITIONS:
9-
// SLA Definition target = "Resolution"
10-
// Run only if task is Incident or SC Task
11-
// (current.task.sys_class_name == 'incident' || current.task.sys_class_name == 'sc_task')
12-
13-
// STEP 1:
14-
// Get the related Incident record from current.task reference
15-
var inc = new GlideRecord('incident'); // Query Incident table
16-
inc.get(current.task); // Fetch the matching incident record
17-
18-
// Update Incident’s custom field to store the Resolution SLA reference
19-
inc.u_resolution_sla = current.sys_id; // Set current task_sla sys_id
20-
inc.update(); // Save changes to Incident
21-
22-
// STEP 2:
23-
// Get the related Task record from current.task reference
24-
var tsk = new GlideRecord('task'); // Query Task table
25-
tsk.get(current.task); // Fetch the task (incident/sc_task/etc.)
26-
27-
// Update Task’s custom field to store the Resolution SLA reference
28-
tsk.u_task_resolution_sla = current.sys_id; // Set current task_sla sys_id
29-
tsk.update(); // Save changes to Task
11+
// Check if state is changing to 'Closed Complete'
12+
if (state == 'closed_complete') {
13+
// Check additional conditions
14+
if (type == 'walkup' && relatedTask == 'true') {
15+
return true; // Allow form submission
16+
} else if (!workNotes) { // Check if work notes is empty
17+
g_form.showFieldMsg('work_notes', 'Provide Worknotes for FCR Interaction', 'error');
18+
alert('Provide Worknotes for FCR Interaction');
19+
return false; // Prevent form submission
20+
}
21+
}
22+
return true; // Allow form submission for other states
23+
}

0 commit comments

Comments
 (0)