From 21b615f12031c3d78653b5c67b681cf9a69c3799 Mon Sep 17 00:00:00 2001 From: ReddySurendra <130588276+Suri123789@users.noreply.github.com> Date: Tue, 27 May 2025 12:30:58 +0530 Subject: [PATCH 1/8] Code for Moveworks bot messages for Flow to include url links --- Moveworks messages html for Flow | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Moveworks messages html for Flow diff --git a/Moveworks messages html for Flow b/Moveworks messages html for Flow new file mode 100644 index 0000000000..c228104146 --- /dev/null +++ b/Moveworks messages html for Flow @@ -0,0 +1,38 @@ +var article = fd_data._1__look_up_record.record; + +// Safely retrieve fields with null checks for a KB Article +var sys_id = article.sys_id || ''; +var articleTitle = article.short_description || 'N/A'; +var requestedBy = fd_data.trigger.current.sys_created_by; +var articleNumber = article.number || 'N/A'; +var requestedOn = article.sys_created_on || 'N/A'; +var kbName = (article.kb_knowledge_base && article.kb_knowledge_base.title) || 'N/A'; +var knowledgeManagers = (article.kb_knowledge_base && article.kb_knowledge_base.owner && article.kb_knowledge_base.owner.getDisplayValue()) || 'N/A'; + +// Base URL +var baseUrl = gs.getProperty('glide.servlet.uri') || ''; +var kbLink = baseUrl + 'kb_knowledge.do?sys_id=' + sys_id; +//Below are links for opening the record in servicenow +var approveLink = baseUrl + 'sysapproval_approver.do?action=approve&sys_id=' + sys_id; +var rejectLink = baseUrl + 'sysapproval_approver.do?action=reject&sys_id=' + sys_id; +//Below lines are for email template which is used to create email inbound template. +var inst ='inspirebrandsdev'; +var approveSub = 'RE: '+ articleNumber +' Approve KB Article '; +var body = 'Please do not change the subject, just click send message.'; +var rejectSub = 'RE: '+ articleNumber +' Reject KB Article '; + + +// HTML message +var message = + 'Pending approval request from ServiceNow

' + + '' + articleNumber + ': ' + articleTitle + '

' + + 'Requested by: ' + requestedBy + '
' + + 'Requested on: ' + requestedOn + '
' + + 'Knowledge Base: ' + kbName + '
' + + 'Knowledge Managers: ' + knowledgeManagers + '

' + + 'Approve link : Click here
'+ + 'Reject link : Click here
'; + //'Approve link : Click here to approve
' + + //'Reject link: Click here to reject'; + +return message; From 701d8db340df55dd556ec8c99ac63d20fad65fa5 Mon Sep 17 00:00:00 2001 From: ReddySurendra <130588276+Suri123789@users.noreply.github.com> Date: Thu, 30 Oct 2025 11:34:21 +0530 Subject: [PATCH 2/8] Delete Moveworks messages html for Flow --- Moveworks messages html for Flow | 38 -------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 Moveworks messages html for Flow diff --git a/Moveworks messages html for Flow b/Moveworks messages html for Flow deleted file mode 100644 index c228104146..0000000000 --- a/Moveworks messages html for Flow +++ /dev/null @@ -1,38 +0,0 @@ -var article = fd_data._1__look_up_record.record; - -// Safely retrieve fields with null checks for a KB Article -var sys_id = article.sys_id || ''; -var articleTitle = article.short_description || 'N/A'; -var requestedBy = fd_data.trigger.current.sys_created_by; -var articleNumber = article.number || 'N/A'; -var requestedOn = article.sys_created_on || 'N/A'; -var kbName = (article.kb_knowledge_base && article.kb_knowledge_base.title) || 'N/A'; -var knowledgeManagers = (article.kb_knowledge_base && article.kb_knowledge_base.owner && article.kb_knowledge_base.owner.getDisplayValue()) || 'N/A'; - -// Base URL -var baseUrl = gs.getProperty('glide.servlet.uri') || ''; -var kbLink = baseUrl + 'kb_knowledge.do?sys_id=' + sys_id; -//Below are links for opening the record in servicenow -var approveLink = baseUrl + 'sysapproval_approver.do?action=approve&sys_id=' + sys_id; -var rejectLink = baseUrl + 'sysapproval_approver.do?action=reject&sys_id=' + sys_id; -//Below lines are for email template which is used to create email inbound template. -var inst ='inspirebrandsdev'; -var approveSub = 'RE: '+ articleNumber +' Approve KB Article '; -var body = 'Please do not change the subject, just click send message.'; -var rejectSub = 'RE: '+ articleNumber +' Reject KB Article '; - - -// HTML message -var message = - 'Pending approval request from ServiceNow

' + - '' + articleNumber + ': ' + articleTitle + '

' + - 'Requested by: ' + requestedBy + '
' + - 'Requested on: ' + requestedOn + '
' + - 'Knowledge Base: ' + kbName + '
' + - 'Knowledge Managers: ' + knowledgeManagers + '

' + - 'Approve link : Click here
'+ - 'Reject link : Click here
'; - //'Approve link : Click here to approve
' + - //'Reject link: Click here to reject'; - -return message; From 71ce1e5b6533bcffcf4f39cfbfb1ff1d655c6d5b Mon Sep 17 00:00:00 2001 From: ReddySurendra <130588276+Suri123789@users.noreply.github.com> Date: Fri, 31 Oct 2025 09:03:24 +0530 Subject: [PATCH 3/8] Create script.js --- .../script.js | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 Client-Side Components/Client Scripts/Auto Priority Update based on Impact and Urgency/script.js diff --git a/Client-Side Components/Client Scripts/Auto Priority Update based on Impact and Urgency/script.js b/Client-Side Components/Client Scripts/Auto Priority Update based on Impact and Urgency/script.js new file mode 100644 index 0000000000..769f4c481e --- /dev/null +++ b/Client-Side Components/Client Scripts/Auto Priority Update based on Impact and Urgency/script.js @@ -0,0 +1,56 @@ +// ========================================================================== +// Script Name: Auto Priority Update based on Impact and Urgency +// Table: Incident (or any Task-based table) +// Type: onChange | Fields: impact, urgency +// UI Type: All +// ========================================================================== + +function onChange(control, oldValue, newValue, isLoading, isTemplate) { + // Prevent the script from running when the form loads or when the field is empty + if (isLoading || newValue == '') { + return; + } + + // ---------------------------------------------------------------------- + // Step 1: Fetch field values from the form + // ---------------------------------------------------------------------- + var impact = g_form.getValue('impact'); // e.g., 1 - High, 2 - Medium, 3 - Low + var urgency = g_form.getValue('urgency'); // e.g., 1 - High, 2 - Medium, 3 - Low + + // ---------------------------------------------------------------------- + // Step 2: Define the ITIL-based Priority Matrix + // ---------------------------------------------------------------------- + // Each row represents "Impact", and each column represents "Urgency" + // The resulting value sets the "Priority" + var priorityMatrix = { + '1': { '1': '1', '2': '2', '3': '3' }, // Impact = High + '2': { '1': '2', '2': '3', '3': '4' }, // Impact = Medium + '3': { '1': '3', '2': '4', '3': '5' } // Impact = Low + }; + + // ---------------------------------------------------------------------- + // Step 3: Determine the new priority based on selected Impact/Urgency + // ---------------------------------------------------------------------- + var newPriority = priorityMatrix[impact]?.[urgency]; // optional chaining prevents errors + + // ---------------------------------------------------------------------- + // Step 4: Update the Priority field and inform the user + // ---------------------------------------------------------------------- + if (newPriority) { + // Only update if priority is different from current value + if (g_form.getValue('priority') != newPriority) { + g_form.setValue('priority', newPriority); + + // Show message (works in both Classic UI and Next Experience) + g_form.showFieldMsg('priority', 'Priority auto-updated based on Impact and Urgency', 'info'); + } + } else { + // Optional: clear priority if invalid combination is selected + g_form.clearValue('priority'); + g_form.showFieldMsg('priority', 'Invalid Impact/Urgency combination β€” priority cleared', 'error'); + } + + // ---------------------------------------------------------------------- + // End of Script + // ---------------------------------------------------------------------- +} From 5d925c3b8a2edffbedb1b5771ca01c7819eca635 Mon Sep 17 00:00:00 2001 From: ReddySurendra <130588276+Suri123789@users.noreply.github.com> Date: Fri, 31 Oct 2025 09:04:38 +0530 Subject: [PATCH 4/8] Create readme.md --- .../readme.md | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 Client-Side Components/Client Scripts/Auto Priority Update based on Impact and Urgency/readme.md diff --git a/Client-Side Components/Client Scripts/Auto Priority Update based on Impact and Urgency/readme.md b/Client-Side Components/Client Scripts/Auto Priority Update based on Impact and Urgency/readme.md new file mode 100644 index 0000000000..8d1628deb7 --- /dev/null +++ b/Client-Side Components/Client Scripts/Auto Priority Update based on Impact and Urgency/readme.md @@ -0,0 +1,81 @@ +🧩 Readme : Client Script: Auto Priority Update Based on Impact and Urgency +πŸ“˜ Overview + +This client script automatically updates the Priority field on the Incident form whenever the Impact or Urgency value changes. +It follows the ITIL standard mapping to ensure the correct priority is always set automatically, improving data accuracy and efficiency for service desk agents. + +βš™οΈ Script Details +Field Value +Name Auto Priority Update based on Impact and Urgency +Type onChange +Applies to Table Incident +Applies on Fields impact, urgency +UI Type All (Classic, Mobile, Workspace) +Active βœ… Yes +Condition Leave blank +πŸ’» Script Code +// ========================================================================== +// Script Name: Auto Priority Update based on Impact and Urgency +// Table: Incident +// Type: onChange | Fields: impact, urgency +// UI Type: All +// Version: 2025 Production Ready +// ========================================================================== + +function onChange(control, oldValue, newValue, isLoading, isTemplate) { + // Skip execution if form is loading or field is empty + if (isLoading || newValue == '') { + return; + } + + // Get Impact and Urgency values + var impact = g_form.getValue('impact'); + var urgency = g_form.getValue('urgency'); + + // Define Priority Matrix (ITIL standard) + var priorityMatrix = { + '1': { '1': '1', '2': '2', '3': '3' }, + '2': { '1': '2', '2': '3', '3': '4' }, + '3': { '1': '3', '2': '4', '3': '5' } + }; + + // Find the new Priority + var newPriority = priorityMatrix[impact]?.[urgency]; + + // Update the Priority field if valid + if (newPriority) { + if (g_form.getValue('priority') != newPriority) { + g_form.setValue('priority', newPriority); + g_form.showFieldMsg('priority', 'Priority auto-updated based on Impact and Urgency', 'info'); + } + } else { + // Optional: Clear Priority if invalid combination is selected + g_form.clearValue('priority'); + g_form.showFieldMsg('priority', 'Invalid Impact/Urgency combination β€” priority cleared', 'error'); + } +} + +🧠 How It Works + +The script runs automatically when Impact or Urgency changes. +It checks the ITIL-based matrix to determine the correct Priority. +If a valid combination is found, the Priority field updates automatically. +A small info message appears to confirm the update. + +πŸ”’ ITIL Mapping Table +Impact Urgency Resulting Priority +1 (High) 1 (High) 1 (Critical) +1 2 2 +1 3 3 +2 1 2 +2 2 3 +2 3 4 +3 1 3 +3 2 4 +3 3 5 +βœ… Benefits + +Automatically enforces ITIL priority standards +Reduces manual effort and user errors +Ensures consistency in priority calculation +Compatible with Classic UI, Next Experience, and Agent Workspace From dc4bb9cefc2f024dc794f9c3477fd732600b2615 Mon Sep 17 00:00:00 2001 From: ReddySurendra <130588276+Suri123789@users.noreply.github.com> Date: Fri, 31 Oct 2025 09:22:54 +0530 Subject: [PATCH 5/8] Create script.js --- .../script.js | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Client-Side Components/Client Scripts/Prevent Rejection Without Comments/script.js diff --git a/Client-Side Components/Client Scripts/Prevent Rejection Without Comments/script.js b/Client-Side Components/Client Scripts/Prevent Rejection Without Comments/script.js new file mode 100644 index 0000000000..8661d77e41 --- /dev/null +++ b/Client-Side Components/Client Scripts/Prevent Rejection Without Comments/script.js @@ -0,0 +1,23 @@ +//Prevent Rejection Without Comments +function onSubmit() { + // Get the current state value of the approval record + var state = g_form.getValue('state'); + + // Get the comments entered by the approver + var comments = g_form.getValue('comments'); + + // Check if the approver is trying to REJECT the record + // The out-of-box (OOB) value for rejection in sysapproval_approver is "rejected" + // If state is 'rejected' and comments are empty, stop the submission + if (state == 'rejected' && !comments) { + + // Display an error message to the user + g_form.addErrorMessage('Please provide comments before rejecting the approval.'); + + // Prevent the form from being submitted (block save/update) + return false; + } + + // Allow the form submission if validation passes + return true; +} From b9e37bec6733e6a907b7bc73443a7e2206bfcea0 Mon Sep 17 00:00:00 2001 From: ReddySurendra <130588276+Suri123789@users.noreply.github.com> Date: Fri, 31 Oct 2025 09:23:58 +0530 Subject: [PATCH 6/8] Create readme.md --- .../readme.md | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 Client-Side Components/Client Scripts/Prevent Rejection Without Comments/readme.md diff --git a/Client-Side Components/Client Scripts/Prevent Rejection Without Comments/readme.md b/Client-Side Components/Client Scripts/Prevent Rejection Without Comments/readme.md new file mode 100644 index 0000000000..8476b55a5f --- /dev/null +++ b/Client-Side Components/Client Scripts/Prevent Rejection Without Comments/readme.md @@ -0,0 +1,72 @@ +🧩 Readme: Prevent Rejection Without Comments – Client Script +πŸ“˜ Overview + +This Client Script enforces that approvers must enter comments before rejecting a record in the Approval [sysapproval_approver] table. +It ensures accountability, audit readiness, and clear justification for rejection decisions. + +🧠 Use Case +Field Details +Table sysapproval_approver +Type Client Script – onSubmit +Purpose Prevent users from rejecting approvals without comments +Business Value Ensures transparency and proper audit trail in approval workflows +βš™οΈ Configuration Steps + +Navigate to System Definition β†’ Client Scripts. + +Click New. + +Fill the form as follows: + +Field Value +Name Prevent Rejection Without Comments +Table sysapproval_approver +UI Type All +Type onSubmit +Active βœ… +Applies on Update + +Paste the following script in the Script field. + +πŸ’» Script +function onSubmit() { + // Get the current state value of the approval record + var state = g_form.getValue('state'); + + // Get the comments entered by the approver + var comments = g_form.getValue('comments'); + + // Check if the approver is trying to REJECT the record + // The out-of-box (OOB) value for rejection in sysapproval_approver is "rejected" + // If state is 'rejected' and comments are empty, stop the submission + if (state == 'rejected' && !comments) { + + // Display an error message to the user + g_form.addErrorMessage('Please provide comments before rejecting the approval.'); + + // Prevent the form from being submitted (block save/update) + return false; + } + + // Allow the form submission if validation passes + return true; +} + +πŸ§ͺ Example Scenario +Field Value +Approver John Doe +State Rejected +Comments (empty) + +User Action: Clicks Update +System Response: Shows error message β€” + +β€œPlease provide comments before rejecting the approval.” +Record submission is blocked until comments are provided. + +βœ… Expected Outcome +🚫 Prevents rejection without comments +⚠️ Displays user-friendly validation message +πŸ“ Ensures that every rejection has a reason logged for compliance + + From 591fc46df6803e7cf32c105f988bf6074480f82f Mon Sep 17 00:00:00 2001 From: ReddySurendra <130588276+Suri123789@users.noreply.github.com> Date: Fri, 31 Oct 2025 09:25:17 +0530 Subject: [PATCH 7/8] Delete Client-Side Components/Client Scripts/Auto Priority Update based on Impact and Urgency/readme.md --- .../readme.md | 81 ------------------- 1 file changed, 81 deletions(-) delete mode 100644 Client-Side Components/Client Scripts/Auto Priority Update based on Impact and Urgency/readme.md diff --git a/Client-Side Components/Client Scripts/Auto Priority Update based on Impact and Urgency/readme.md b/Client-Side Components/Client Scripts/Auto Priority Update based on Impact and Urgency/readme.md deleted file mode 100644 index 8d1628deb7..0000000000 --- a/Client-Side Components/Client Scripts/Auto Priority Update based on Impact and Urgency/readme.md +++ /dev/null @@ -1,81 +0,0 @@ -🧩 Readme : Client Script: Auto Priority Update Based on Impact and Urgency -πŸ“˜ Overview - -This client script automatically updates the Priority field on the Incident form whenever the Impact or Urgency value changes. -It follows the ITIL standard mapping to ensure the correct priority is always set automatically, improving data accuracy and efficiency for service desk agents. - -βš™οΈ Script Details -Field Value -Name Auto Priority Update based on Impact and Urgency -Type onChange -Applies to Table Incident -Applies on Fields impact, urgency -UI Type All (Classic, Mobile, Workspace) -Active βœ… Yes -Condition Leave blank -πŸ’» Script Code -// ========================================================================== -// Script Name: Auto Priority Update based on Impact and Urgency -// Table: Incident -// Type: onChange | Fields: impact, urgency -// UI Type: All -// Version: 2025 Production Ready -// ========================================================================== - -function onChange(control, oldValue, newValue, isLoading, isTemplate) { - // Skip execution if form is loading or field is empty - if (isLoading || newValue == '') { - return; - } - - // Get Impact and Urgency values - var impact = g_form.getValue('impact'); - var urgency = g_form.getValue('urgency'); - - // Define Priority Matrix (ITIL standard) - var priorityMatrix = { - '1': { '1': '1', '2': '2', '3': '3' }, - '2': { '1': '2', '2': '3', '3': '4' }, - '3': { '1': '3', '2': '4', '3': '5' } - }; - - // Find the new Priority - var newPriority = priorityMatrix[impact]?.[urgency]; - - // Update the Priority field if valid - if (newPriority) { - if (g_form.getValue('priority') != newPriority) { - g_form.setValue('priority', newPriority); - g_form.showFieldMsg('priority', 'Priority auto-updated based on Impact and Urgency', 'info'); - } - } else { - // Optional: Clear Priority if invalid combination is selected - g_form.clearValue('priority'); - g_form.showFieldMsg('priority', 'Invalid Impact/Urgency combination β€” priority cleared', 'error'); - } -} - -🧠 How It Works - -The script runs automatically when Impact or Urgency changes. -It checks the ITIL-based matrix to determine the correct Priority. -If a valid combination is found, the Priority field updates automatically. -A small info message appears to confirm the update. - -πŸ”’ ITIL Mapping Table -Impact Urgency Resulting Priority -1 (High) 1 (High) 1 (Critical) -1 2 2 -1 3 3 -2 1 2 -2 2 3 -2 3 4 -3 1 3 -3 2 4 -3 3 5 -βœ… Benefits - -Automatically enforces ITIL priority standards -Reduces manual effort and user errors -Ensures consistency in priority calculation -Compatible with Classic UI, Next Experience, and Agent Workspace From a45065198b1cc037848e2a4daac1491fac0ee618 Mon Sep 17 00:00:00 2001 From: ReddySurendra <130588276+Suri123789@users.noreply.github.com> Date: Fri, 31 Oct 2025 09:25:41 +0530 Subject: [PATCH 8/8] Delete Client-Side Components/Client Scripts/Auto Priority Update based on Impact and Urgency/script.js --- .../script.js | 56 ------------------- 1 file changed, 56 deletions(-) delete mode 100644 Client-Side Components/Client Scripts/Auto Priority Update based on Impact and Urgency/script.js diff --git a/Client-Side Components/Client Scripts/Auto Priority Update based on Impact and Urgency/script.js b/Client-Side Components/Client Scripts/Auto Priority Update based on Impact and Urgency/script.js deleted file mode 100644 index 769f4c481e..0000000000 --- a/Client-Side Components/Client Scripts/Auto Priority Update based on Impact and Urgency/script.js +++ /dev/null @@ -1,56 +0,0 @@ -// ========================================================================== -// Script Name: Auto Priority Update based on Impact and Urgency -// Table: Incident (or any Task-based table) -// Type: onChange | Fields: impact, urgency -// UI Type: All -// ========================================================================== - -function onChange(control, oldValue, newValue, isLoading, isTemplate) { - // Prevent the script from running when the form loads or when the field is empty - if (isLoading || newValue == '') { - return; - } - - // ---------------------------------------------------------------------- - // Step 1: Fetch field values from the form - // ---------------------------------------------------------------------- - var impact = g_form.getValue('impact'); // e.g., 1 - High, 2 - Medium, 3 - Low - var urgency = g_form.getValue('urgency'); // e.g., 1 - High, 2 - Medium, 3 - Low - - // ---------------------------------------------------------------------- - // Step 2: Define the ITIL-based Priority Matrix - // ---------------------------------------------------------------------- - // Each row represents "Impact", and each column represents "Urgency" - // The resulting value sets the "Priority" - var priorityMatrix = { - '1': { '1': '1', '2': '2', '3': '3' }, // Impact = High - '2': { '1': '2', '2': '3', '3': '4' }, // Impact = Medium - '3': { '1': '3', '2': '4', '3': '5' } // Impact = Low - }; - - // ---------------------------------------------------------------------- - // Step 3: Determine the new priority based on selected Impact/Urgency - // ---------------------------------------------------------------------- - var newPriority = priorityMatrix[impact]?.[urgency]; // optional chaining prevents errors - - // ---------------------------------------------------------------------- - // Step 4: Update the Priority field and inform the user - // ---------------------------------------------------------------------- - if (newPriority) { - // Only update if priority is different from current value - if (g_form.getValue('priority') != newPriority) { - g_form.setValue('priority', newPriority); - - // Show message (works in both Classic UI and Next Experience) - g_form.showFieldMsg('priority', 'Priority auto-updated based on Impact and Urgency', 'info'); - } - } else { - // Optional: clear priority if invalid combination is selected - g_form.clearValue('priority'); - g_form.showFieldMsg('priority', 'Invalid Impact/Urgency combination β€” priority cleared', 'error'); - } - - // ---------------------------------------------------------------------- - // End of Script - // ---------------------------------------------------------------------- -}