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 4f0531a0201d99f924e1468ecd056df243389d92 Mon Sep 17 00:00:00 2001 From: ReddySurendra <130588276+Suri123789@users.noreply.github.com> Date: Wed, 29 Oct 2025 16:50:07 +0530 Subject: [PATCH 2/4] Create script.js --- .../script.js | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Server-Side Components/Business Rules/Populate Resolution SLA for Incidents/script.js diff --git a/Server-Side Components/Business Rules/Populate Resolution SLA for Incidents/script.js b/Server-Side Components/Business Rules/Populate Resolution SLA for Incidents/script.js new file mode 100644 index 0000000000..307f00a1d9 --- /dev/null +++ b/Server-Side Components/Business Rules/Populate Resolution SLA for Incidents/script.js @@ -0,0 +1,29 @@ +// Business Rule: Set Resolution SLA on Related Tasks +// Table: task_sla +// When: After Insert + +// PURPOSE: +// When a new Task SLA is created for Resolution SLA, update the related records. + +// CONDITIONS: +// SLA Definition target = "Resolution" +// Run only if task is Incident or SC Task +// (current.task.sys_class_name == 'incident' || current.task.sys_class_name == 'sc_task') + +// STEP 1: +// Get the related Incident record from current.task reference +var inc = new GlideRecord('incident'); // Query Incident table +inc.get(current.task); // Fetch the matching incident record + +// Update Incident’s custom field to store the Resolution SLA reference +inc.u_resolution_sla = current.sys_id; // Set current task_sla sys_id +inc.update(); // Save changes to Incident + +// STEP 2: +// Get the related Task record from current.task reference +var tsk = new GlideRecord('task'); // Query Task table +tsk.get(current.task); // Fetch the task (incident/sc_task/etc.) + +// Update Task’s custom field to store the Resolution SLA reference +tsk.u_task_resolution_sla = current.sys_id; // Set current task_sla sys_id +tsk.update(); // Save changes to Task From 9de1e8f674c271907bd88b66b3fb7b7bd95c5802 Mon Sep 17 00:00:00 2001 From: ReddySurendra <130588276+Suri123789@users.noreply.github.com> Date: Wed, 29 Oct 2025 16:50:53 +0530 Subject: [PATCH 3/4] Create readme.md --- .../readme.md | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Server-Side Components/Business Rules/Populate Resolution SLA for Incidents/readme.md diff --git a/Server-Side Components/Business Rules/Populate Resolution SLA for Incidents/readme.md b/Server-Side Components/Business Rules/Populate Resolution SLA for Incidents/readme.md new file mode 100644 index 0000000000..1e1101744f --- /dev/null +++ b/Server-Side Components/Business Rules/Populate Resolution SLA for Incidents/readme.md @@ -0,0 +1,63 @@ +📘 README — Auto Update Resolution SLA on Related Tasks +Business Rule Details + +Name: Auto Update Resolution SLA Reference +Table: task_sla +Execution: After Insert +Filter Condition: SLA Definition target must be Resolution +Condition: Runs only when the associated task is an Incident or a Catalog Task +(current.task.sys_class_name == 'incident' || current.task.sys_class_name == 'sc_task') + +Purpose + +This Business Rule is designed to automatically update the related Incident and Task records with the Resolution SLA reference when a new Task SLA record is created. +It helps provide direct visibility of SLA details from the Incident or Task form without navigating to the task_sla table. + +How It Works + +A new Resolution SLA is created for a task. + +This rule triggers after the Task SLA record is inserted. + +It checks if the related task is an Incident or a Catalog Task. + +It updates the custom SLA reference fields on both the Incident and the Task. + +Prerequisites + +You must create the following fields before using this rule: + +Field: u_resolution_sla (On Incident table) +Type: Reference to task_sla + +Field: u_task_resolution_sla (On Task table) +Type: Reference to task_sla + +Testing Steps + +• Create a new Incident and associate a Resolution SLA with it. +• Allow the SLA to start (so it creates a task_sla entry). +• Open the Incident and related Task. +• You should see the Resolution SLA reference auto-populated in both. + +Script Used +(function executeRule(current, previous /*null when async*/ ) { + + var inc = new GlideRecord('incident'); + inc.get(current.task); + + inc.u_resolution_sla = current.sys_id; + inc.update(); + + var tsk = new GlideRecord('task'); + tsk.get(current.task); + + tsk.u_task_resolution_sla = current.sys_id; + tsk.update(); + +})(current, previous); + +Result + +This automation ensures the SLA is visible and reportable on both Incident and Task records with no manual updates. +It improves SLA tracking, reporting, and overall usability. From 194ad68cfd6fb2e4f01d771e0f7b45a4eef55136 Mon Sep 17 00:00:00 2001 From: ReddySurendra <130588276+Suri123789@users.noreply.github.com> Date: Wed, 29 Oct 2025 16:53:23 +0530 Subject: [PATCH 4/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;