@@ -11,17 +11,69 @@ Provides visual feedback for empty mandatory fields on ServiceNow forms by showi
1111## Implementation
12121 . Create a new Client Script with Type "onLoad"
13132 . Copy the script code from script.js
14- 3 . Apply to desired table/form
15- 4 . Save and test on a form with mandatory fields
14+ 3 . ** Customize the fieldsToCheck string** with your form's mandatory field names
15+ 4 . Apply to desired table/form
16+ 5 . Save and test on a form with mandatory fields
17+
18+ ## Configuration
19+ Edit the ` fieldsToCheck ` variable to include your form's mandatory fields as a comma-separated string:
20+
21+ ``` javascript
22+ // Example configurations for different forms:
23+
24+ // For Incident forms:
25+ var fieldsToCheck = ' short_description,priority,category,caller_id,assignment_group' ;
26+
27+ // For Request forms:
28+ var fieldsToCheck = ' short_description,requested_for,category,priority' ;
29+
30+ // For Change Request forms:
31+ var fieldsToCheck = ' short_description,category,priority,assignment_group,start_date,end_date' ;
32+
33+ // For Problem forms:
34+ var fieldsToCheck = ' short_description,category,priority,assignment_group' ;
35+
36+ // Custom fields (add as needed):
37+ var fieldsToCheck = ' short_description,priority,u_business_justification,u_cost_center' ;
38+ ```
1639
1740## Features
1841- Shows error messages under empty mandatory fields on form load
42+ - Easy configuration with comma-separated field names
43+ - Automatically skips fields that don't exist on the form
44+ - Only processes fields that are actually mandatory and visible
1945- Uses proper ServiceNow client scripting APIs
2046- No DOM manipulation or unsupported methods
21- - Lightweight and focused functionality
47+
48+ ## Common Field Names
49+ - ` short_description ` - Short Description
50+ - ` priority ` - Priority
51+ - ` category ` - Category
52+ - ` caller_id ` - Caller
53+ - ` requested_for ` - Requested For
54+ - ` assignment_group ` - Assignment Group
55+ - ` assigned_to ` - Assigned To
56+ - ` state ` - State
57+ - ` urgency ` - Urgency
58+ - ` impact ` - Impact
59+ - ` start_date ` - Start Date
60+ - ` end_date ` - End Date
61+ - ` due_date ` - Due Date
62+ - ` location ` - Location
63+ - ` company ` - Company
64+ - ` department ` - Department
2265
2366## Notes
2467- Uses g_form.showFieldMsg() method to display error messages
25- - Only runs on form load - no real-time updates
26- - Works with all mandatory fields automatically
27- - Simple single-script solution
68+ - Uses g_form.hasField() to safely check field existence (built into the safety checks)
69+ - Only runs on form load - provides initial validation feedback
70+ - Easy to customize for different forms by modifying the field list
71+ - Compatible with all standard ServiceNow forms
72+ - Lightweight and focused on essential functionality
73+
74+ ## Example Usage
75+ For a typical incident form, simply change the configuration line to:
76+ ``` javascript
77+ var fieldsToCheck = ' short_description,priority,category,caller_id,assignment_group' ;
78+ ```
79+ Save the Client Script and test on an incident form to see error messages appear under empty mandatory fields.
0 commit comments