From 124fef6492a338b46e7ee52244d8483e3341d3f7 Mon Sep 17 00:00:00 2001 From: GHSayak25 <59216790+GHSayak25@users.noreply.github.com> Date: Sun, 12 Oct 2025 23:05:17 +0530 Subject: [PATCH 1/2] Fetch Already Associated Records using Script Include --- .../Script Includes/Get Already Associated Records/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Server-Side Components/Script Includes/Get Already Associated Records/README.md diff --git a/Server-Side Components/Script Includes/Get Already Associated Records/README.md b/Server-Side Components/Script Includes/Get Already Associated Records/README.md new file mode 100644 index 0000000000..76c354589b --- /dev/null +++ b/Server-Side Components/Script Includes/Get Already Associated Records/README.md @@ -0,0 +1,3 @@ +We can use javascript to build a query and inside that script we can call a script include to fetch already associated records which we can utilize in other logic. + +image From 3af3fbe7b4041086b55c0dc08e54d674562f394e Mon Sep 17 00:00:00 2001 From: GHSayak25 <59216790+GHSayak25@users.noreply.github.com> Date: Sun, 12 Oct 2025 23:10:48 +0530 Subject: [PATCH 2/2] Check already associated records and use them in filter query --- .../getAlreadyAssociatedRecords.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Server-Side Components/Script Includes/Get Already Associated Records/getAlreadyAssociatedRecords.js diff --git a/Server-Side Components/Script Includes/Get Already Associated Records/getAlreadyAssociatedRecords.js b/Server-Side Components/Script Includes/Get Already Associated Records/getAlreadyAssociatedRecords.js new file mode 100644 index 0000000000..4e1410c96f --- /dev/null +++ b/Server-Side Components/Script Includes/Get Already Associated Records/getAlreadyAssociatedRecords.js @@ -0,0 +1,22 @@ +//Check if there is already record existing for a particular Issue to Item. + +var getAlreadyAssociatedRecords = Class.create(); +getAlreadyAssociatedRecords.prototype = Object.extendsObject(global.AbstractAjaxProcessor, { + + getSysIdsItem: function(issueId) { + + var alreadyAssociatedContent = []; + var gr = new GlideRecord('sn_grc_m2m_issue_item'); + gr.addQuery('sn_grc_issue', issueId); + gr.query(); + + while (gr.next()) { + if (!gr.sn_grc_item.nil()) + alreadyAssociatedContent.push(gr.getValue('sn_grc_item').toString()); + } + return alreadyAssociatedContent.join(','); + + }, + + type: 'getAlreadyAssociatedRecords' +});