Skip to content

Commit 598bfd9

Browse files
authored
Create readme.md
1 parent 08744d3 commit 598bfd9

File tree

1 file changed

+78
-0
lines changed
  • Client Scripts/validate Interaction record

1 file changed

+78
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
README — Client Script: Validate Interaction Resolution
2+
📌 Purpose
3+
This Client Script ensures proper validation when resolving an Interaction record in ServiceNow.
4+
It prevents a user from marking an Interaction as Closed Complete without proper justification.
5+
6+
🎯 What It Does
7+
8+
When a user attempts to submit the form:
9+
10+
✔ Allows submission only if:
11+
12+
Interaction Type is "walkup"
13+
14+
And Related Task Boolean is true
15+
16+
OR
17+
18+
✔ If work notes are provided for First Contact Resolution (FCR)
19+
20+
❌ Prevents submission if:
21+
22+
State = Closed Complete
23+
24+
Work Notes are empty
25+
26+
And no related task condition is met
27+
28+
🧠 Validations Performed
29+
Field Condition Action
30+
state closed_complete Trigger validation
31+
type walkup AND u_boolean_no_related_task = true Submission allowed ✅
32+
work_notes Must not be empty Show error & stop submission ❌
33+
🔔 User Feedback
34+
35+
If work notes are missing:
36+
37+
Displays inline field message
38+
39+
Shows popup alert:
40+
"Provide Worknotes for FCR Interaction"
41+
42+
📍 Script Location
43+
44+
Client Script → Type: onSubmit()
45+
Applicable to Interaction table (interaction)
46+
47+
📌 Script Code
48+
//Client Script to validate an Interaction record is resolved with out any related record created.
49+
function onSubmit() {
50+
var relatedTask = g_form.getValue('u_boolean_no_related_task');
51+
var state = g_form.getValue('state');
52+
var type = g_form.getValue('type');
53+
var workNotes = g_form.getValue('work_notes'); // Get the value of work notes
54+
55+
// Clear previous field messages
56+
g_form.clearMessages();
57+
58+
// Check if state is changing to 'Closed Complete'
59+
if (state == 'closed_complete') {
60+
// Check additional conditions
61+
if (type == 'walkup' && relatedTask == 'true') {
62+
return true; // Allow form submission
63+
} else if (!workNotes) { // Check if work notes is empty
64+
g_form.showFieldMsg('work_notes', 'Provide Worknotes for FCR Interaction', 'error');
65+
alert('Provide Worknotes for FCR Interaction');
66+
return false; // Prevent form submission
67+
}
68+
}
69+
return true; // Allow form submission for other states
70+
}
71+
72+
✅ Benefits
73+
74+
Maintains consistent resolution standards
75+
76+
Ensures justification/documentation for FCR interactions
77+
78+
Reduces incorrect closure of requests without related actions

0 commit comments

Comments
 (0)