From af09eba1b8ad51d4f247027e2041f76bf5aa327d Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Tue, 7 Oct 2025 19:04:08 +0530 Subject: [PATCH 1/5] Create Create Incident Task With Same Group --- .../Create Incident Task With Same Group | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Core ServiceNow APIs/GlideRecord/getEncodedQuery/Create Incident Task With Same Group diff --git a/Core ServiceNow APIs/GlideRecord/getEncodedQuery/Create Incident Task With Same Group b/Core ServiceNow APIs/GlideRecord/getEncodedQuery/Create Incident Task With Same Group new file mode 100644 index 0000000000..ac54bc4a62 --- /dev/null +++ b/Core ServiceNow APIs/GlideRecord/getEncodedQuery/Create Incident Task With Same Group @@ -0,0 +1,13 @@ +var incRec = new GlideRecord('incident'); +incRec.addEncodedQuery('assignment_group=287ee6fea9fe198100ada7950d0b1b73^active=true'); // encoded Query to get incients assigned to particular group +incRec.query(); +var eQry = incRec.getEncodedQuery(); + +while(incRec.next()){ + var iTask = new GlideRecord('incident_task'); + iTask.initialize(); + iTask.applyEncodedQuery(eQry); + iTask.setValue('incident', incRec.getUniqueValue()); + iTask.insert(); +} + From 2a02f84672a9ca2ac6061acce13f6fea0aacd9dc Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Tue, 7 Oct 2025 19:13:44 +0530 Subject: [PATCH 2/5] Update README.md --- Core ServiceNow APIs/GlideRecord/getEncodedQuery/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Core ServiceNow APIs/GlideRecord/getEncodedQuery/README.md b/Core ServiceNow APIs/GlideRecord/getEncodedQuery/README.md index 0d8b0e17e9..634c82c494 100644 --- a/Core ServiceNow APIs/GlideRecord/getEncodedQuery/README.md +++ b/Core ServiceNow APIs/GlideRecord/getEncodedQuery/README.md @@ -1,3 +1,7 @@ +/* This script will glide all active incidents assigned to a particular group and create incident task with same group. + This make use of applyEncodedQuery. +*/ + 1.In any GlideRecord query retrieve query using getEncodedQuery() 2.Apply this encoded query to create/update records (you can apply this query to other tables if query is appropriate). From 678c09fb1b9a9c555abd853f2e9894a9a3a68c31 Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Tue, 7 Oct 2025 19:39:45 +0530 Subject: [PATCH 3/5] Update Create Incident Task With Same Group --- .../getEncodedQuery/Create Incident Task With Same Group | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Core ServiceNow APIs/GlideRecord/getEncodedQuery/Create Incident Task With Same Group b/Core ServiceNow APIs/GlideRecord/getEncodedQuery/Create Incident Task With Same Group index ac54bc4a62..fd1e9f73d4 100644 --- a/Core ServiceNow APIs/GlideRecord/getEncodedQuery/Create Incident Task With Same Group +++ b/Core ServiceNow APIs/GlideRecord/getEncodedQuery/Create Incident Task With Same Group @@ -1,12 +1,12 @@ var incRec = new GlideRecord('incident'); -incRec.addEncodedQuery('assignment_group=287ee6fea9fe198100ada7950d0b1b73^active=true'); // encoded Query to get incients assigned to particular group +incRec.addEncodedQuery('assignment_group=287ee6fea9fe198100ada7950d0b1b73^active=true'); // sys_id of assignment group is used. Return active incidents assigned to group. incRec.query(); -var eQry = incRec.getEncodedQuery(); +var eQry = incRec.getEncodedQuery(); // return the encoded query, applied above. while(incRec.next()){ var iTask = new GlideRecord('incident_task'); iTask.initialize(); - iTask.applyEncodedQuery(eQry); + iTask.applyEncodedQuery(eQry); // applies the encoded query fields to new incident task record. iTask.setValue('incident', incRec.getUniqueValue()); iTask.insert(); } From 18c33c1dbece70624405cb2a176c0686acb7e155 Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Tue, 7 Oct 2025 19:42:55 +0530 Subject: [PATCH 4/5] Update README.md --- Core ServiceNow APIs/GlideRecord/getEncodedQuery/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Core ServiceNow APIs/GlideRecord/getEncodedQuery/README.md b/Core ServiceNow APIs/GlideRecord/getEncodedQuery/README.md index 634c82c494..eab94c629e 100644 --- a/Core ServiceNow APIs/GlideRecord/getEncodedQuery/README.md +++ b/Core ServiceNow APIs/GlideRecord/getEncodedQuery/README.md @@ -1,5 +1,8 @@ /* This script will glide all active incidents assigned to a particular group and create incident task with same group. - This make use of applyEncodedQuery. +This was a client requirement, where for a particular group they wanted a task generated to log some internal extra work they were doing, during some of their internal transition. +This was done through a scheduled job (daily) for the required period and then the scheduled job was deactivated. + +sys_id in script is of the group being used. */ 1.In any GlideRecord query retrieve query using getEncodedQuery() From e9c6bcbf3299d72cba5091f12d6926280a0a6d23 Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Tue, 7 Oct 2025 19:44:33 +0530 Subject: [PATCH 5/5] Update README.md --- Core ServiceNow APIs/GlideRecord/getEncodedQuery/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Core ServiceNow APIs/GlideRecord/getEncodedQuery/README.md b/Core ServiceNow APIs/GlideRecord/getEncodedQuery/README.md index eab94c629e..6e72fa12c7 100644 --- a/Core ServiceNow APIs/GlideRecord/getEncodedQuery/README.md +++ b/Core ServiceNow APIs/GlideRecord/getEncodedQuery/README.md @@ -2,6 +2,8 @@ This was a client requirement, where for a particular group they wanted a task generated to log some internal extra work they were doing, during some of their internal transition. This was done through a scheduled job (daily) for the required period and then the scheduled job was deactivated. +This can be further used in scenarios where organizations want to log some extra work in a different record. + sys_id in script is of the group being used. */