Field Help Text Toggler
Show contextual help text or tooltips for specific fields to guide users, with ability to toggle help on/off.
onLoad Table: incident
#onLoad #help #tooltip #user-guidance #training #user-experience
Script Code
JavaScript
1function onLoad() {
2 // Configuration: Define help text for each field
3 var fieldHelpText = {
4 'category': {
5 title: 'Incident Category',
6 text: 'Select the primary category that best describes this incident. ' +
7 'This determines routing and priority calculations.',
8 examples: ['Hardware issues: Physical device problems',
9 'Software: Application errors or bugs',
10 'Network: Connectivity or bandwidth issues']
11 },
12 'impact': {
13 title: 'Business Impact',
14 text: 'Assess how many users or services are affected by this incident.',
15 examples: ['1 - High: Multiple departments or critical services',
16 '2 - Medium: Single department or non-critical service',
17 '3 - Low: Individual user or minimal business impact']
18 },
19 'urgency': {
20 title: 'Urgency Level',
21 text: 'How quickly does this incident need to be resolved?',
22 examples: ['1 - High: Business operations stopped',
23 '2 - Medium: Degraded service, workaround available',
24 '3 - Low: Minimal impact, can be scheduled']
25 },
26 'short_description': {
27 title: 'Short Description',
28 text: 'Provide a brief, clear summary of the issue (50-100 characters). ' +
29 'This appears in list views and notifications.',
30 examples: ['Good: "Email server down - cannot send/receive"',
31 'Bad: "Problem with email"']
32 },
33 'description': {
34 title: 'Detailed Description',
35 text: 'Provide comprehensive information including:\n' +
36 '• What happened?\n' +
37 '• When did it start?\n' +
38 '• What were you doing?\n' +
39 '• Error messages or screenshots\n' +
40 '• Steps to reproduce',
41 examples: []
42 },
43 'assignment_group': {
44 title: 'Assignment Group',
45 text: 'Select the team responsible for resolving this type of incident. ' +
46 'If unsure, leave blank and it will be routed automatically.',
47 examples: []
48 }
49 };
50
51 // Track help visibility state
52 var helpVisible = false;
53
54 // Function to show help for a field
55 function showFieldHelp(fieldName) {
56 var help = fieldHelpText[fieldName];
57 if (!help) return;
58
59 var helpMessage = '<div style="margin: 10px 0;">' +
60 '<strong>' + help.title + '</strong><br/>' +
61 help.text;
62
63 if (help.examples && help.examples.length > 0) {
64 helpMessage += '<br/><br/><em>Examples:</em><ul style="margin: 5px 0;">';
65 help.examples.forEach(function(example) {
66 helpMessage += '<li>' + example + '</li>';
67 });
68 helpMessage += '</ul>';
69 }
70
71 helpMessage += '</div>';
72
73 g_form.showFieldMsg(fieldName, helpMessage, 'info', false);
74 }
75
76 // Function to hide all help messages
77 function hideAllHelp() {
78 Object.keys(fieldHelpText).forEach(function(fieldName) {
79 g_form.hideFieldMsg(fieldName);
80 });
81 }
82
83 // Function to toggle help display
84 function toggleHelp() {
85 helpVisible = !helpVisible;
86
87 if (helpVisible) {
88 // Show help for all configured fields
89 Object.keys(fieldHelpText).forEach(function(fieldName) {
90 showFieldHelp(fieldName);
91 });
92 g_form.addInfoMessage('Field help enabled. Click "Hide Help" to dismiss.');
93 } else {
94 // Hide all help
95 hideAllHelp();
96 g_form.clearMessages();
97 }
98 }
99
100 // Add toggle button as info message with link
101 var toggleLink = '<a href="javascript:void(0)" onclick="toggleHelp()" ' +
102 'style="font-weight: bold; text-decoration: underline;">' +
103 'Show Field Help</a>';
104
105 g_form.addInfoMessage('Need help filling out this form? ' + toggleLink);
106
107 // Make toggleHelp available globally
108 window.toggleHelp = toggleHelp;
109
110 // Show help for specific fields on focus (optional)
111 Object.keys(fieldHelpText).forEach(function(fieldName) {
112 // Add focus event listener
113 var field = g_form.getField(fieldName);
114 if (field) {
115 // Note: Direct DOM manipulation should be used carefully
116 // This is a simplified example
117 }
118 });
119
120 // Auto-show help for required empty fields
121 if (g_form.isNewRecord()) {
122 var requiredFields = ['short_description', 'category'];
123 requiredFields.forEach(function(fieldName) {
124 if (!g_form.getValue(fieldName) && fieldHelpText[fieldName]) {
125 showFieldHelp(fieldName);
126 }
127 });
128 }
129}
How to Use
1. Create an onLoad Client Script on your table
2. Customize fieldHelpText object with your fields and help content
3. Add examples and guidance specific to your organization
4. Consider adding help toggle to UI Policy or custom button
5. Test help visibility and formatting
6. Update help text based on user feedback
7. Consider internationalization for multi-language support
Related Scripts
Auto-populate Related Fields
Automatically populate fields when a reference field changes (e.g., populate caller's phone and email when caller is selected).
Conditional Mandatory Fields
Make fields mandatory based on the value of another field (e.g., require close notes only when state is Resolved).
Dynamic Field Visibility
Show or hide fields based on another field's value (e.g., show "Other reason" field only when user selects "Other" from dropdown).