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/4] 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/4] 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 11c3bdc45d0ee0b6320f83d69ab1e84b2e1f884a Mon Sep 17 00:00:00 2001 From: ReddySurendra <130588276+Suri123789@users.noreply.github.com> Date: Fri, 31 Oct 2025 08:57:24 +0530 Subject: [PATCH 3/4] Create script.js --- .../script.js | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 Auto Priority Update based on Impact and Urgency/script.js diff --git a/Auto Priority Update based on Impact and Urgency/script.js b/Auto Priority Update based on Impact and Urgency/script.js new file mode 100644 index 0000000000..769f4c481e --- /dev/null +++ b/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 8e9983b34203c225d989febe19d01fa7f5317ab3 Mon Sep 17 00:00:00 2001 From: ReddySurendra <130588276+Suri123789@users.noreply.github.com> Date: Fri, 31 Oct 2025 08:59:23 +0530 Subject: [PATCH 4/4] Create readme.md --- .../readme.md | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 Auto Priority Update based on Impact and Urgency/readme.md diff --git a/Auto Priority Update based on Impact and Urgency/readme.md b/Auto Priority Update based on Impact and Urgency/readme.md new file mode 100644 index 0000000000..8d1628deb7 --- /dev/null +++ b/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