From b5fbaa36dfbe9426ebf53b98e07b693cea392e65 Mon Sep 17 00:00:00 2001 From: Yelugu Sriharsha <89392618+Sriharsha19@users.noreply.github.com> Date: Sat, 11 Oct 2025 17:14:52 +0530 Subject: [PATCH 1/8] Created Smart Field Suggestions --- .../Client Scripts/Smart Field Suggestions | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 Client-Side Components/Client Scripts/Smart Field Suggestions diff --git a/Client-Side Components/Client Scripts/Smart Field Suggestions b/Client-Side Components/Client Scripts/Smart Field Suggestions new file mode 100644 index 0000000000..b3af251bbc --- /dev/null +++ b/Client-Side Components/Client Scripts/Smart Field Suggestions @@ -0,0 +1,73 @@ +function onChange(control, oldValue, newValue, isLoading, isTemplate) { + if (isLoading || !newValue || newValue.length < 10) { + return; + } + + var keywords = [ + { + pattern: /password|login|access/i, + category: 'inquiry | Help ', + subcategory: 'antivirus', + priority: '3', + suggestion: 'This appears to be a Inquiry issue.' + }, + { + pattern: /slow|performance|hanging/i, + category: 'software', + subcategory: 'email', + priority: '2', + suggestion: 'This appears to be a Software issue.' + }, + { + pattern: /printer|print|printing/i, + category: 'hardware', + subcategory: 'monitor', + priority: '3', + suggestion: 'This appears to be a Hardware issue.' + }, + { + pattern: /database|data/i, + category: 'database', + subcategory: 'db2', + priority: '3', + suggestion: 'This appears to be an Database issue.' + }, + { + pattern: /network|internet|wifi|connection/i, + category: 'network', + subcategory: 'vpn', + priority: '2', + suggestion: 'This appears to be a network issue.' + } + + ]; + + var lowerDesc = newValue.toLowerCase(); + var matched = null; + + for (var i = 0; i < keywords.length; i++) { + if (keywords[i].pattern.test(lowerDesc)) { + matched = keywords[i]; + break; + } + } + + g_form.hideFieldMsg('short_description', true); + g_form.clearMessages(); + + if (matched) { + g_form.showFieldMsg('short_description', matched.suggestion, 'info', false); + + if (confirm(matched.suggestion + "\n\nApply these suggestions?")) { + g_form.setValue('category', matched.category); + g_form.setValue('subcategory', matched.subcategory); // Make sure you use backend value for subcategory! + g_form.setValue('priority', matched.priority); + g_form.addInfoMessage('Suggestions applied automatically!'); + } else { + g_form.addInfoMessage('Suggestions dismissed.'); + g_form.hideFieldMsg('short_description', true); + } + } else { + g_form.addInfoMessage('No keywords matched in description.'); + } +} From 5c02e40abaf42ef44ffb0de3e539d492e9f096fb Mon Sep 17 00:00:00 2001 From: Yelugu Sriharsha <89392618+Sriharsha19@users.noreply.github.com> Date: Sat, 11 Oct 2025 17:17:37 +0530 Subject: [PATCH 2/8] deleting the file to move file to a folder --- .../Client Scripts/Smart Field Suggestions | 73 ------------------- 1 file changed, 73 deletions(-) delete mode 100644 Client-Side Components/Client Scripts/Smart Field Suggestions diff --git a/Client-Side Components/Client Scripts/Smart Field Suggestions b/Client-Side Components/Client Scripts/Smart Field Suggestions deleted file mode 100644 index b3af251bbc..0000000000 --- a/Client-Side Components/Client Scripts/Smart Field Suggestions +++ /dev/null @@ -1,73 +0,0 @@ -function onChange(control, oldValue, newValue, isLoading, isTemplate) { - if (isLoading || !newValue || newValue.length < 10) { - return; - } - - var keywords = [ - { - pattern: /password|login|access/i, - category: 'inquiry | Help ', - subcategory: 'antivirus', - priority: '3', - suggestion: 'This appears to be a Inquiry issue.' - }, - { - pattern: /slow|performance|hanging/i, - category: 'software', - subcategory: 'email', - priority: '2', - suggestion: 'This appears to be a Software issue.' - }, - { - pattern: /printer|print|printing/i, - category: 'hardware', - subcategory: 'monitor', - priority: '3', - suggestion: 'This appears to be a Hardware issue.' - }, - { - pattern: /database|data/i, - category: 'database', - subcategory: 'db2', - priority: '3', - suggestion: 'This appears to be an Database issue.' - }, - { - pattern: /network|internet|wifi|connection/i, - category: 'network', - subcategory: 'vpn', - priority: '2', - suggestion: 'This appears to be a network issue.' - } - - ]; - - var lowerDesc = newValue.toLowerCase(); - var matched = null; - - for (var i = 0; i < keywords.length; i++) { - if (keywords[i].pattern.test(lowerDesc)) { - matched = keywords[i]; - break; - } - } - - g_form.hideFieldMsg('short_description', true); - g_form.clearMessages(); - - if (matched) { - g_form.showFieldMsg('short_description', matched.suggestion, 'info', false); - - if (confirm(matched.suggestion + "\n\nApply these suggestions?")) { - g_form.setValue('category', matched.category); - g_form.setValue('subcategory', matched.subcategory); // Make sure you use backend value for subcategory! - g_form.setValue('priority', matched.priority); - g_form.addInfoMessage('Suggestions applied automatically!'); - } else { - g_form.addInfoMessage('Suggestions dismissed.'); - g_form.hideFieldMsg('short_description', true); - } - } else { - g_form.addInfoMessage('No keywords matched in description.'); - } -} From c7ab30529035c3a52947a1144e1fa9a4ccbd2f58 Mon Sep 17 00:00:00 2001 From: Yelugu Sriharsha <89392618+Sriharsha19@users.noreply.github.com> Date: Sat, 11 Oct 2025 17:28:43 +0530 Subject: [PATCH 3/8] Moved Incident-smart-field-suggestion file to Smart-field-sugeestion folder . --- .../Smart-field-suggestions/Script.js | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 Client-Side Components/Smart-field-suggestions/Script.js diff --git a/Client-Side Components/Smart-field-suggestions/Script.js b/Client-Side Components/Smart-field-suggestions/Script.js new file mode 100644 index 0000000000..b3af251bbc --- /dev/null +++ b/Client-Side Components/Smart-field-suggestions/Script.js @@ -0,0 +1,73 @@ +function onChange(control, oldValue, newValue, isLoading, isTemplate) { + if (isLoading || !newValue || newValue.length < 10) { + return; + } + + var keywords = [ + { + pattern: /password|login|access/i, + category: 'inquiry | Help ', + subcategory: 'antivirus', + priority: '3', + suggestion: 'This appears to be a Inquiry issue.' + }, + { + pattern: /slow|performance|hanging/i, + category: 'software', + subcategory: 'email', + priority: '2', + suggestion: 'This appears to be a Software issue.' + }, + { + pattern: /printer|print|printing/i, + category: 'hardware', + subcategory: 'monitor', + priority: '3', + suggestion: 'This appears to be a Hardware issue.' + }, + { + pattern: /database|data/i, + category: 'database', + subcategory: 'db2', + priority: '3', + suggestion: 'This appears to be an Database issue.' + }, + { + pattern: /network|internet|wifi|connection/i, + category: 'network', + subcategory: 'vpn', + priority: '2', + suggestion: 'This appears to be a network issue.' + } + + ]; + + var lowerDesc = newValue.toLowerCase(); + var matched = null; + + for (var i = 0; i < keywords.length; i++) { + if (keywords[i].pattern.test(lowerDesc)) { + matched = keywords[i]; + break; + } + } + + g_form.hideFieldMsg('short_description', true); + g_form.clearMessages(); + + if (matched) { + g_form.showFieldMsg('short_description', matched.suggestion, 'info', false); + + if (confirm(matched.suggestion + "\n\nApply these suggestions?")) { + g_form.setValue('category', matched.category); + g_form.setValue('subcategory', matched.subcategory); // Make sure you use backend value for subcategory! + g_form.setValue('priority', matched.priority); + g_form.addInfoMessage('Suggestions applied automatically!'); + } else { + g_form.addInfoMessage('Suggestions dismissed.'); + g_form.hideFieldMsg('short_description', true); + } + } else { + g_form.addInfoMessage('No keywords matched in description.'); + } +} From a395d9934e96d85063b11ba34170ab7d9977cdbd Mon Sep 17 00:00:00 2001 From: Yelugu Sriharsha <89392618+Sriharsha19@users.noreply.github.com> Date: Sat, 11 Oct 2025 17:37:57 +0530 Subject: [PATCH 4/8] Create README.md --- .../Smart-field-suggestions/README.md | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Client-Side Components/Smart-field-suggestions/README.md diff --git a/Client-Side Components/Smart-field-suggestions/README.md b/Client-Side Components/Smart-field-suggestions/README.md new file mode 100644 index 0000000000..d1ad144959 --- /dev/null +++ b/Client-Side Components/Smart-field-suggestions/README.md @@ -0,0 +1,31 @@ +# Smart Field Suggestions Based on Keywords + +## Category +Client-Side Components / Client Scripts + +## Description +This is an onChange Client Script designed for the Incident table that dynamically suggests and populates the Category, Subcategory, and Priority fields based on keywords detected in the Short Description field. By matching keywords, it prompts users to confirm applying suggestions aligned with backend choice values for seamless integration. + +## Use Case +During incident creation or update, manually categorizing tickets correctly is critical for IT operations efficiency. This snippet automates early triage by analyzing user-entered short descriptions, providing actionable suggestions to improve categorization accuracy, accelerate routing, and enhance resolution speed. + +## How to Use +- Add this script as an "onChange" client script on the Incident table's `short_description` field. +- Ensure the Category, Subcategory, and Priority fields have choice lists aligned with backend values specified in the snippet. +- Modify the keyword list to align with your organizational terminologies if needed. +- The user will be prompted with suggestions and may confirm or dismiss them, allowing balanced automation and human control. + +## Why This Use Case is Unique and Valuable + +- Dynamically assists in categorizing incidents early, improving routing and resolution time. +- Uses only platform APIs (`g_form`) without custom backend code or external integrations, making it lightweight and maintainable. +- Uses real backend choice values ensuring seamless compatibility with existing configurations, reducing errors. +- Provides prompt suggestions with user confirmation, balancing automation and user control. +- Easily adaptable for other fields, keywords, or use cases beyond Incident management. +- Designed without fragile DOM manipulations, following ServiceNow best practices, tailored for real environments. + +## Compatibility +This client script is compatible with all ServiceNow instances . + +## Files +- `Script.js` — the client script implementing the logic. From 03195777271c80f3fac6c03dc1f2a62faff041f7 Mon Sep 17 00:00:00 2001 From: Yelugu Sriharsha <89392618+Sriharsha19@users.noreply.github.com> Date: Sat, 11 Oct 2025 17:49:52 +0530 Subject: [PATCH 5/8] Deleting the README.md it is not in right path --- .../Smart-field-suggestions/README.md | 31 ------------------- 1 file changed, 31 deletions(-) delete mode 100644 Client-Side Components/Smart-field-suggestions/README.md diff --git a/Client-Side Components/Smart-field-suggestions/README.md b/Client-Side Components/Smart-field-suggestions/README.md deleted file mode 100644 index d1ad144959..0000000000 --- a/Client-Side Components/Smart-field-suggestions/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# Smart Field Suggestions Based on Keywords - -## Category -Client-Side Components / Client Scripts - -## Description -This is an onChange Client Script designed for the Incident table that dynamically suggests and populates the Category, Subcategory, and Priority fields based on keywords detected in the Short Description field. By matching keywords, it prompts users to confirm applying suggestions aligned with backend choice values for seamless integration. - -## Use Case -During incident creation or update, manually categorizing tickets correctly is critical for IT operations efficiency. This snippet automates early triage by analyzing user-entered short descriptions, providing actionable suggestions to improve categorization accuracy, accelerate routing, and enhance resolution speed. - -## How to Use -- Add this script as an "onChange" client script on the Incident table's `short_description` field. -- Ensure the Category, Subcategory, and Priority fields have choice lists aligned with backend values specified in the snippet. -- Modify the keyword list to align with your organizational terminologies if needed. -- The user will be prompted with suggestions and may confirm or dismiss them, allowing balanced automation and human control. - -## Why This Use Case is Unique and Valuable - -- Dynamically assists in categorizing incidents early, improving routing and resolution time. -- Uses only platform APIs (`g_form`) without custom backend code or external integrations, making it lightweight and maintainable. -- Uses real backend choice values ensuring seamless compatibility with existing configurations, reducing errors. -- Provides prompt suggestions with user confirmation, balancing automation and user control. -- Easily adaptable for other fields, keywords, or use cases beyond Incident management. -- Designed without fragile DOM manipulations, following ServiceNow best practices, tailored for real environments. - -## Compatibility -This client script is compatible with all ServiceNow instances . - -## Files -- `Script.js` — the client script implementing the logic. From 006fc9c9c46a6087bd16be05c876b3916b05d953 Mon Sep 17 00:00:00 2001 From: Yelugu Sriharsha <89392618+Sriharsha19@users.noreply.github.com> Date: Sat, 11 Oct 2025 17:50:54 +0530 Subject: [PATCH 6/8] Delete Client-Side Components/Smart-field-suggestions/Script.js as it is placed in wrong path --- .../Smart-field-suggestions/Script.js | 73 ------------------- 1 file changed, 73 deletions(-) delete mode 100644 Client-Side Components/Smart-field-suggestions/Script.js diff --git a/Client-Side Components/Smart-field-suggestions/Script.js b/Client-Side Components/Smart-field-suggestions/Script.js deleted file mode 100644 index b3af251bbc..0000000000 --- a/Client-Side Components/Smart-field-suggestions/Script.js +++ /dev/null @@ -1,73 +0,0 @@ -function onChange(control, oldValue, newValue, isLoading, isTemplate) { - if (isLoading || !newValue || newValue.length < 10) { - return; - } - - var keywords = [ - { - pattern: /password|login|access/i, - category: 'inquiry | Help ', - subcategory: 'antivirus', - priority: '3', - suggestion: 'This appears to be a Inquiry issue.' - }, - { - pattern: /slow|performance|hanging/i, - category: 'software', - subcategory: 'email', - priority: '2', - suggestion: 'This appears to be a Software issue.' - }, - { - pattern: /printer|print|printing/i, - category: 'hardware', - subcategory: 'monitor', - priority: '3', - suggestion: 'This appears to be a Hardware issue.' - }, - { - pattern: /database|data/i, - category: 'database', - subcategory: 'db2', - priority: '3', - suggestion: 'This appears to be an Database issue.' - }, - { - pattern: /network|internet|wifi|connection/i, - category: 'network', - subcategory: 'vpn', - priority: '2', - suggestion: 'This appears to be a network issue.' - } - - ]; - - var lowerDesc = newValue.toLowerCase(); - var matched = null; - - for (var i = 0; i < keywords.length; i++) { - if (keywords[i].pattern.test(lowerDesc)) { - matched = keywords[i]; - break; - } - } - - g_form.hideFieldMsg('short_description', true); - g_form.clearMessages(); - - if (matched) { - g_form.showFieldMsg('short_description', matched.suggestion, 'info', false); - - if (confirm(matched.suggestion + "\n\nApply these suggestions?")) { - g_form.setValue('category', matched.category); - g_form.setValue('subcategory', matched.subcategory); // Make sure you use backend value for subcategory! - g_form.setValue('priority', matched.priority); - g_form.addInfoMessage('Suggestions applied automatically!'); - } else { - g_form.addInfoMessage('Suggestions dismissed.'); - g_form.hideFieldMsg('short_description', true); - } - } else { - g_form.addInfoMessage('No keywords matched in description.'); - } -} From a636a9569c4f4fc1ef9e86a608419860d9d9bf4b Mon Sep 17 00:00:00 2001 From: Yelugu Sriharsha <89392618+Sriharsha19@users.noreply.github.com> Date: Sat, 11 Oct 2025 17:53:18 +0530 Subject: [PATCH 7/8] Created Smart Field Suggestions Based on Keyword.js in Correct Path --- ...mart Field Suggestions Based on Keyword.js | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 Client-Side Components/Client Scripts/Smart-Field-Suggestions/Smart Field Suggestions Based on Keyword.js diff --git a/Client-Side Components/Client Scripts/Smart-Field-Suggestions/Smart Field Suggestions Based on Keyword.js b/Client-Side Components/Client Scripts/Smart-Field-Suggestions/Smart Field Suggestions Based on Keyword.js new file mode 100644 index 0000000000..b3af251bbc --- /dev/null +++ b/Client-Side Components/Client Scripts/Smart-Field-Suggestions/Smart Field Suggestions Based on Keyword.js @@ -0,0 +1,73 @@ +function onChange(control, oldValue, newValue, isLoading, isTemplate) { + if (isLoading || !newValue || newValue.length < 10) { + return; + } + + var keywords = [ + { + pattern: /password|login|access/i, + category: 'inquiry | Help ', + subcategory: 'antivirus', + priority: '3', + suggestion: 'This appears to be a Inquiry issue.' + }, + { + pattern: /slow|performance|hanging/i, + category: 'software', + subcategory: 'email', + priority: '2', + suggestion: 'This appears to be a Software issue.' + }, + { + pattern: /printer|print|printing/i, + category: 'hardware', + subcategory: 'monitor', + priority: '3', + suggestion: 'This appears to be a Hardware issue.' + }, + { + pattern: /database|data/i, + category: 'database', + subcategory: 'db2', + priority: '3', + suggestion: 'This appears to be an Database issue.' + }, + { + pattern: /network|internet|wifi|connection/i, + category: 'network', + subcategory: 'vpn', + priority: '2', + suggestion: 'This appears to be a network issue.' + } + + ]; + + var lowerDesc = newValue.toLowerCase(); + var matched = null; + + for (var i = 0; i < keywords.length; i++) { + if (keywords[i].pattern.test(lowerDesc)) { + matched = keywords[i]; + break; + } + } + + g_form.hideFieldMsg('short_description', true); + g_form.clearMessages(); + + if (matched) { + g_form.showFieldMsg('short_description', matched.suggestion, 'info', false); + + if (confirm(matched.suggestion + "\n\nApply these suggestions?")) { + g_form.setValue('category', matched.category); + g_form.setValue('subcategory', matched.subcategory); // Make sure you use backend value for subcategory! + g_form.setValue('priority', matched.priority); + g_form.addInfoMessage('Suggestions applied automatically!'); + } else { + g_form.addInfoMessage('Suggestions dismissed.'); + g_form.hideFieldMsg('short_description', true); + } + } else { + g_form.addInfoMessage('No keywords matched in description.'); + } +} From 993574c5afcf784358c19f7966071ac8217fd036 Mon Sep 17 00:00:00 2001 From: Yelugu Sriharsha <89392618+Sriharsha19@users.noreply.github.com> Date: Sat, 11 Oct 2025 18:00:23 +0530 Subject: [PATCH 8/8] Created README.md file in correct path --- .../Smart-Field-Suggestions/README.md | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Client-Side Components/Client Scripts/Smart-Field-Suggestions/README.md diff --git a/Client-Side Components/Client Scripts/Smart-Field-Suggestions/README.md b/Client-Side Components/Client Scripts/Smart-Field-Suggestions/README.md new file mode 100644 index 0000000000..fe418b6e0d --- /dev/null +++ b/Client-Side Components/Client Scripts/Smart-Field-Suggestions/README.md @@ -0,0 +1,33 @@ +# Smart Field Suggestions Based on Keywords + +## Category +Client-Side Components / Client Scripts + +## Description +This is an onChange Client Script designed for the Incident table that dynamically suggests and populates the Category, Subcategory, and Priority fields based on keywords detected in the Short Description field. By matching keywords, it prompts users to confirm applying suggestions aligned with backend choice values for seamless integration. + +## Use Case +During incident creation or update, manually categorizing tickets correctly is critical for IT operations efficiency. This snippet automates early triage by analyzing user-entered short descriptions, providing actionable suggestions to improve categorization accuracy, accelerate routing, and enhance resolution speed. + +## How to Use +- Add this script as an "onChange" client script on the Incident table's `short_description` field. +- Ensure the Category, Subcategory, and Priority fields have choice lists aligned with backend values specified in the snippet. +- Modify the keyword list to align with your organizational terminologies if needed. +- The user will be prompted with suggestions and may confirm or dismiss them, allowing balanced automation and human control. + +## Why This Use Case is Unique and Valuable + +- Dynamically assists in categorizing incidents early, improving routing and resolution time. +- Uses only platform APIs (`g_form`) without custom backend code or external integrations, making it lightweight and maintainable. +- Uses real backend choice values ensuring seamless compatibility with existing configurations, reducing errors. +- Provides prompt suggestions with user confirmation, balancing automation and user control. +- Easily adaptable for other fields, keywords, or use cases beyond Incident management. +- Designed without fragile DOM manipulations, following ServiceNow best practices, tailored for real environments. + +## Compatibility +This client script is compatible with all standard ServiceNow instances without requiring ES2021 features. + +## Files +- `Smart Field Suggestions Based on Keyword.js` — the client script implementing the logic. + +