From d4401e86e317604fcf74ab816a46a945efebe72e Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Fri, 1 Oct 2021 17:15:21 -0500
Subject: [PATCH 01/38] Create Regex Validation
---
Catalog Client Script/Regex Validation | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
create mode 100644 Catalog Client Script/Regex Validation
diff --git a/Catalog Client Script/Regex Validation b/Catalog Client Script/Regex Validation
new file mode 100644
index 0000000000..243fea9c14
--- /dev/null
+++ b/Catalog Client Script/Regex Validation
@@ -0,0 +1,16 @@
+function onChange(control, oldValue, newValue, isLoading) {
+ if (isLoading || newValue == '') {
+ return;
+ }
+ //Defining the regular expression to validate if the given value is valid email address or not
+ var emailValidation = /^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/;
+ if (!emailValidation.test(newValue)) {
+ g_form.clearValue('VARIABLE_NAME'); // Clear's the variable
+ g_form.showFieldMsg('VARIABLE_NAME', 'Please enter a valid email address', 'error'); // Display a message below variable
+ return false; // Stop submission
+ }
+ return true;
+}
+
+
+
From 18454b2e1235b7892998991a3d129664ef5f5461 Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Fri, 1 Oct 2021 17:24:08 -0500
Subject: [PATCH 02/38] Delete Regex Validation
---
Catalog Client Script/Regex Validation | 16 ----------------
1 file changed, 16 deletions(-)
delete mode 100644 Catalog Client Script/Regex Validation
diff --git a/Catalog Client Script/Regex Validation b/Catalog Client Script/Regex Validation
deleted file mode 100644
index 243fea9c14..0000000000
--- a/Catalog Client Script/Regex Validation
+++ /dev/null
@@ -1,16 +0,0 @@
-function onChange(control, oldValue, newValue, isLoading) {
- if (isLoading || newValue == '') {
- return;
- }
- //Defining the regular expression to validate if the given value is valid email address or not
- var emailValidation = /^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/;
- if (!emailValidation.test(newValue)) {
- g_form.clearValue('VARIABLE_NAME'); // Clear's the variable
- g_form.showFieldMsg('VARIABLE_NAME', 'Please enter a valid email address', 'error'); // Display a message below variable
- return false; // Stop submission
- }
- return true;
-}
-
-
-
From 420703ec7107beb7faac5c1e937b982cc4015621 Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Fri, 1 Oct 2021 17:24:42 -0500
Subject: [PATCH 03/38] Create script.js
---
Catalog Client Script/Regex Validation/script.js | 12 ++++++++++++
1 file changed, 12 insertions(+)
create mode 100644 Catalog Client Script/Regex Validation/script.js
diff --git a/Catalog Client Script/Regex Validation/script.js b/Catalog Client Script/Regex Validation/script.js
new file mode 100644
index 0000000000..e8eb396a26
--- /dev/null
+++ b/Catalog Client Script/Regex Validation/script.js
@@ -0,0 +1,12 @@
+function onChange(control, oldValue, newValue, isLoading) {
+ if (isLoading || newValue == '') {
+ return;
+ }
+ //Defining the regular expression to validate if the given value is valid email address or not
+ var emailValidation = /^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/;
+ if (!emailValidation.test(newValue)) {
+ g_form.clearValue('VARIABLE_NAME'); // Clear's the variable
+ g_form.showFieldMsg('VARIABLE_NAME', 'Please enter a valid email address', 'error'); // Display a message below variable
+ return false; // Stop submission
+ }
+ return true;
From b5048950c368b61bc37dd0be08c02e1edf9066ba Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Fri, 1 Oct 2021 17:29:53 -0500
Subject: [PATCH 04/38] Create readme.md
---
Catalog Client Script/Regex Validation/readme.md | 5 +++++
1 file changed, 5 insertions(+)
create mode 100644 Catalog Client Script/Regex Validation/readme.md
diff --git a/Catalog Client Script/Regex Validation/readme.md b/Catalog Client Script/Regex Validation/readme.md
new file mode 100644
index 0000000000..2b96b0ad29
--- /dev/null
+++ b/Catalog Client Script/Regex Validation/readme.md
@@ -0,0 +1,5 @@
+# Regular Expression on Catalog Client script
+
+ With the help of this code you can easily validate the input value from the user and if it's not a email format you can clear and throw a error message belwo the variable. Of course you can use Email type variable as well but you cannot have a formatted error message.
+
+
From 3f765d9f9096127ace05f309a9cfbf04afabe090 Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Fri, 1 Oct 2021 17:36:56 -0500
Subject: [PATCH 05/38] Update readme.md
---
Catalog Client Script/Regex Validation/readme.md | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/Catalog Client Script/Regex Validation/readme.md b/Catalog Client Script/Regex Validation/readme.md
index 2b96b0ad29..559f9fc04c 100644
--- a/Catalog Client Script/Regex Validation/readme.md
+++ b/Catalog Client Script/Regex Validation/readme.md
@@ -1,5 +1,6 @@
# Regular Expression on Catalog Client script
- With the help of this code you can easily validate the input value from the user and if it's not a email format you can clear and throw a error message belwo the variable. Of course you can use Email type variable as well but you cannot have a formatted error message.
-
+With the help of this code you can easily validate the input value from the user and if it's not a email format you can clear and throw a error message belwo the variable. Of course you can use Email type variable as well but you cannot have a formatted error message.
+
+* [Click here for script] (https://github.com/azeezgaa/code-snippets/blob/main/Catalog%20Client%20Script/Regex%20Validation/script.js)
From 1c8be391404d51ef3900298e6e5d0f7a0910cff5 Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Fri, 1 Oct 2021 17:39:24 -0500
Subject: [PATCH 06/38] Update the script link
---
Catalog Client Script/Regex Validation/readme.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Catalog Client Script/Regex Validation/readme.md b/Catalog Client Script/Regex Validation/readme.md
index 559f9fc04c..e6a1a10d3b 100644
--- a/Catalog Client Script/Regex Validation/readme.md
+++ b/Catalog Client Script/Regex Validation/readme.md
@@ -2,5 +2,6 @@
With the help of this code you can easily validate the input value from the user and if it's not a email format you can clear and throw a error message belwo the variable. Of course you can use Email type variable as well but you cannot have a formatted error message.
-* [Click here for script] (https://github.com/azeezgaa/code-snippets/blob/main/Catalog%20Client%20Script/Regex%20Validation/script.js)
+* [Click here for script](https://github.com/azeezgaa/code-snippets/blob/main/Catalog%20Client%20Script/Regex%20Validation/script.js)
+
From a2cef79f4b59b8731f82ff0bd70df895c04e1cfe Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Fri, 1 Oct 2021 18:01:30 -0500
Subject: [PATCH 07/38] Fixed the relative link
---
Catalog Client Script/Regex Validation/readme.md | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/Catalog Client Script/Regex Validation/readme.md b/Catalog Client Script/Regex Validation/readme.md
index e6a1a10d3b..f4bcb7aff4 100644
--- a/Catalog Client Script/Regex Validation/readme.md
+++ b/Catalog Client Script/Regex Validation/readme.md
@@ -1,7 +1,9 @@
# Regular Expression on Catalog Client script
-With the help of this code you can easily validate the input value from the user and if it's not a email format you can clear and throw a error message belwo the variable. Of course you can use Email type variable as well but you cannot have a formatted error message.
+With the help of this code you can easily validate the input value from the user and if it's not a email format you can clear and throw a error message below the variable. Of course you can use Email type variable as well but you cannot have a formatted error message.
+
+* [Click here for script](script.js)
+
+
-* [Click here for script](https://github.com/azeezgaa/code-snippets/blob/main/Catalog%20Client%20Script/Regex%20Validation/script.js)
-
From 1488c64d6ca519c9e66786df2c39b1f6bc1995a2 Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Mon, 4 Oct 2021 15:40:32 +0530
Subject: [PATCH 08/38] Create onSubmitClientScript.js
---
.../onSubmitClientScript.js | 22 +++++++++++++++++++
1 file changed, 22 insertions(+)
create mode 100644 Catalog Client Script/Mandatory Attachments with 'n' numbers/onSubmitClientScript.js
diff --git a/Catalog Client Script/Mandatory Attachments with 'n' numbers/onSubmitClientScript.js b/Catalog Client Script/Mandatory Attachments with 'n' numbers/onSubmitClientScript.js
new file mode 100644
index 0000000000..a9010291b0
--- /dev/null
+++ b/Catalog Client Script/Mandatory Attachments with 'n' numbers/onSubmitClientScript.js
@@ -0,0 +1,22 @@
+function onSubmit() {
+ //Type appropriate comment here, and begin script below
+
+var count = 3; //Pass the number to ensure given number of attachments are added
+ if(window == null){
+ // Service portal validation, Make sure Isolate Script is set to False
+ if(this.document.getElementsByClassName('get-attachment').length != count) {
+ alert('You must add 3 attachments before submitting this request.');
+ return false;
+ }
+ }
+ else{
+ // Platform View
+ var length = $j("li.attachment_list_items").find("span").length;
+ if(length != count){
+ alert('You must add 3 attachments before submitting this request.');
+ return false;
+ }
+ }
+}
+
+
From 1f25cb8dec0b25940acb345e5c5b982ff67e0d25 Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Mon, 4 Oct 2021 15:47:23 +0530
Subject: [PATCH 09/38] Create readme.md
---
.../Mandatory Attachments with 'n' numbers/readme.md | 8 ++++++++
1 file changed, 8 insertions(+)
create mode 100644 Catalog Client Script/Mandatory Attachments with 'n' numbers/readme.md
diff --git a/Catalog Client Script/Mandatory Attachments with 'n' numbers/readme.md b/Catalog Client Script/Mandatory Attachments with 'n' numbers/readme.md
new file mode 100644
index 0000000000..8411359829
--- /dev/null
+++ b/Catalog Client Script/Mandatory Attachments with 'n' numbers/readme.md
@@ -0,0 +1,8 @@
+# Enable Mandatory Attachments Count wtih 'n' numbers on Service Catalog item
+**Problem:** Check if exact 'n' number of attachments are added or not when user submit a request through service catalog from Portal/Platform UI.
+
+**For example:** We need to ensure there are exact 3 attachments added before submission
+
+**Note:** Ensure Isolate Script field is set to False for this Catalog Client Script to ensure DOM manipulation works
+
+* [Click here for script](onSubmitClientScript.js)
From 2be6635593f956ffbf49deb3712d72b8dc481a5c Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Tue, 5 Oct 2021 16:24:17 -0500
Subject: [PATCH 10/38] Create script.js
---
.../Email Text as Attachment/script.js | 50 +++++++++++++++++++
1 file changed, 50 insertions(+)
create mode 100644 Inbound Actions/Email Text as Attachment/script.js
diff --git a/Inbound Actions/Email Text as Attachment/script.js b/Inbound Actions/Email Text as Attachment/script.js
new file mode 100644
index 0000000000..4560c76322
--- /dev/null
+++ b/Inbound Actions/Email Text as Attachment/script.js
@@ -0,0 +1,50 @@
+
+/**********************************************************************************************************************
+Create a Script Include:
+Name: emailAsAttachmentUtil
+Accessible from: All application Scopes = this will allow it to be called by all applications
+Active: checked
+Description: You may want to set the description to something like the following to document what this script includes does and how to call it
+
+
+This utility script will take contents from an inbound email and create an attachment on the created record from the inbound email action. To utilize this script, add the following lines at the end of the inbound email action script:
+var emailAsAttachment = new global.emailAsAttachmentUtil();
+emailAsAttachment.createAttachment(email, current);
+***********************************************************************************************************************/
+
+var emailAsAttachmentUtil = Class.create();
+emailAsAttachmentUtil.prototype = {
+ initialize: function() {
+ this.newLineChar = "\r\n"; // Microsoft Windows expects \r and \n for return and new line
+ this.contentType = "text/plain";
+ },
+
+ createAttachment: function (emailRec, currentRec) {
+ var fileName = emailRec.subject + '.eml';
+
+ // Setup array to push email values into. Add additional as needed/
+ var emailData = [];
+ emailData.push("To: " + emailRec.to);
+ emailData.push("Subject: " + emailRec.subject);
+ emailData.push("From: " + emailRec.origemail);
+ emailData.push(emailRec.body_text);
+
+ // Convert emailData to a string separated by new line character.
+ var emailString = emailData.join(this.newLineChar);
+
+ // Create attachment with email string and attach it to the record creatd by the email.
+ var sysAttachment = new GlideSysAttachment();
+ sysAttachment.write(currentRec, fileName, this.contentType, emailString);
+ },
+
+ type: 'emailAsAttachmentUtil'
+};
+
+
+/**********************************************************************************************************************
+Navigate to System Policy \ Email \ Inbound Actions and open the one that you want to capture the contents of the email as an attachment.
+Go to the Actions Tab and scroll to the bottom of the script and paste in the following:
+***********************************************************************************************************************/
+
+var emailAttachment = new global.emailAsAttachmentUtil();
+emailAttachment.createAttachment(email, current);
From 5188613f7d3add6040977f713cd3231f69b11a43 Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Tue, 5 Oct 2021 16:32:15 -0500
Subject: [PATCH 11/38] Create readme.md
---
.../Email Text as Attachment/readme.md | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
create mode 100644 Inbound Actions/Email Text as Attachment/readme.md
diff --git a/Inbound Actions/Email Text as Attachment/readme.md b/Inbound Actions/Email Text as Attachment/readme.md
new file mode 100644
index 0000000000..0568ee998b
--- /dev/null
+++ b/Inbound Actions/Email Text as Attachment/readme.md
@@ -0,0 +1,19 @@
+# Save Email Text as Attachment
+
+### Steps:
+
+Navigate to System Definition \ Script Includes and click New.
+Set the following values:
+**Name:** emailAsAttachmentUtil
+**Accessible from:** All application Scopes = this will allow it to be called by all applications
+**Active:** checked
+**Description:** You may want to set the description to something like the following to document what this script includes does and how to call it
+
+
+```js
+This utility script will take contents from an inbound email and create an attachment on the created record from the inbound email action. To utilize this script, add the following lines at the end of the inbound email action script:
+var emailAsAttachment = new global.emailAsAttachmentUtil();
+emailAsAttachment.createAttachment(email, current);
+```
+
+* [Click here for script](script.js)
From 4637862d4b448080cadec5d610f4fef15316bf72 Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Tue, 5 Oct 2021 16:47:36 -0500
Subject: [PATCH 12/38] Create script.js
---
.../MRVS Unique Data selection/script.js | 24 +++++++++++++++++++
1 file changed, 24 insertions(+)
create mode 100644 Catalog Client Script/MRVS Unique Data selection/script.js
diff --git a/Catalog Client Script/MRVS Unique Data selection/script.js b/Catalog Client Script/MRVS Unique Data selection/script.js
new file mode 100644
index 0000000000..394f489998
--- /dev/null
+++ b/Catalog Client Script/MRVS Unique Data selection/script.js
@@ -0,0 +1,24 @@
+//On Change of MRVS reference variable name on which you need to set the unique data selection
+
+function onChange(control, oldValue, newValue, isLoading) {
+ if (isLoading || newValue == '') {
+ return;
+ }
+
+ var MRVS_FIELD = "field_name_here"; // Multi Row Variable set name
+
+ var MRVS = (g_service_catalog.parent.getValue(MRVS_FIELD).length != 0) ? JSON.parse(g_service_catalog.parent.getValue(MRVS_FIELD)) : [];
+
+ //If the MRVS is empty - exit
+ if(MRVS.length == 0)return;
+
+ var valueExists = MRVS.some(function(obj){
+ return obj.reference_variable_name == newValue; //Reference Variable name which you need to make unique data selection
+ });
+
+ if(valueExists){
+ g_form.showFieldMsg(MRVS_FIELD , "Field must be unique");
+ }
+
+
+}
From cf3d34b858ec6b5fe2f976dc3ce62abe56343036 Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Tue, 5 Oct 2021 16:56:53 -0500
Subject: [PATCH 13/38] Create readme.md
---
Catalog Client Script/MRVS Unique Data selection/readme.md | 7 +++++++
1 file changed, 7 insertions(+)
create mode 100644 Catalog Client Script/MRVS Unique Data selection/readme.md
diff --git a/Catalog Client Script/MRVS Unique Data selection/readme.md b/Catalog Client Script/MRVS Unique Data selection/readme.md
new file mode 100644
index 0000000000..9c5906421e
--- /dev/null
+++ b/Catalog Client Script/MRVS Unique Data selection/readme.md
@@ -0,0 +1,7 @@
+# Prevent data selection form MRVS variable
+There are plenty of ways to do this and Queubec servicenow did introduce a new field called Unique (Checkbox) on the MRVS variable, but it works only on Service Portal and Agent workspace view and you cannot set your own message. If you would like to have your own message then you can go with this script.
+
+[Click here for ServiceNow Docs](https://docs.servicenow.com/bundle/quebec-servicenow-platform/page/product/service-catalog-management/task/t_CreateAVariableForACatalogItem.html)
+
+[Click here for script](script.js)
+
From 31a294efebc2201cc4d4f12c936586467ce60a70 Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Tue, 5 Oct 2021 17:31:26 -0500
Subject: [PATCH 14/38] Update readme.md
---
Inbound Actions/Email Text as Attachment/readme.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Inbound Actions/Email Text as Attachment/readme.md b/Inbound Actions/Email Text as Attachment/readme.md
index 0568ee998b..019caef35c 100644
--- a/Inbound Actions/Email Text as Attachment/readme.md
+++ b/Inbound Actions/Email Text as Attachment/readme.md
@@ -9,6 +9,7 @@ Set the following values:
**Active:** checked
**Description:** You may want to set the description to something like the following to document what this script includes does and how to call it
+* [Click here for Script include script](script.js)
```js
This utility script will take contents from an inbound email and create an attachment on the created record from the inbound email action. To utilize this script, add the following lines at the end of the inbound email action script:
@@ -16,4 +17,4 @@ var emailAsAttachment = new global.emailAsAttachmentUtil();
emailAsAttachment.createAttachment(email, current);
```
-* [Click here for script](script.js)
+
From adb18ca7e28485647804136b7ddd7660c4885950 Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Tue, 5 Oct 2021 17:44:53 -0500
Subject: [PATCH 15/38] Updated the text
---
Inbound Actions/Email Text as Attachment/readme.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/Inbound Actions/Email Text as Attachment/readme.md b/Inbound Actions/Email Text as Attachment/readme.md
index 019caef35c..b5b0ee53a0 100644
--- a/Inbound Actions/Email Text as Attachment/readme.md
+++ b/Inbound Actions/Email Text as Attachment/readme.md
@@ -11,6 +11,7 @@ Set the following values:
* [Click here for Script include script](script.js)
+**Sample of calling a script include from the Inbound action**
```js
This utility script will take contents from an inbound email and create an attachment on the created record from the inbound email action. To utilize this script, add the following lines at the end of the inbound email action script:
var emailAsAttachment = new global.emailAsAttachmentUtil();
From ab90cf093dfc910be31e178c017a1f63ff091c77 Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Tue, 5 Oct 2021 17:45:12 -0500
Subject: [PATCH 16/38] Update readme.md
---
Inbound Actions/Email Text as Attachment/readme.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Inbound Actions/Email Text as Attachment/readme.md b/Inbound Actions/Email Text as Attachment/readme.md
index b5b0ee53a0..64b85e4d25 100644
--- a/Inbound Actions/Email Text as Attachment/readme.md
+++ b/Inbound Actions/Email Text as Attachment/readme.md
@@ -11,7 +11,7 @@ Set the following values:
* [Click here for Script include script](script.js)
-**Sample of calling a script include from the Inbound action**
+**Example of calling a script include from the Inbound action**
```js
This utility script will take contents from an inbound email and create an attachment on the created record from the inbound email action. To utilize this script, add the following lines at the end of the inbound email action script:
var emailAsAttachment = new global.emailAsAttachmentUtil();
From 267bb6b45a56599ba0bb505fdc256af10aa700f2 Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Tue, 5 Oct 2021 17:45:38 -0500
Subject: [PATCH 17/38] Update readme.md
---
Inbound Actions/Email Text as Attachment/readme.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Inbound Actions/Email Text as Attachment/readme.md b/Inbound Actions/Email Text as Attachment/readme.md
index 64b85e4d25..5389103ac1 100644
--- a/Inbound Actions/Email Text as Attachment/readme.md
+++ b/Inbound Actions/Email Text as Attachment/readme.md
@@ -13,7 +13,7 @@ Set the following values:
**Example of calling a script include from the Inbound action**
```js
-This utility script will take contents from an inbound email and create an attachment on the created record from the inbound email action. To utilize this script, add the following lines at the end of the inbound email action script:
+//This utility script will take contents from an inbound email and create an attachment on the created record from the inbound email action. To utilize this script, add the following lines at the end of the inbound email action script:
var emailAsAttachment = new global.emailAsAttachmentUtil();
emailAsAttachment.createAttachment(email, current);
```
From 6b12627ba57bc6f93866e90088090c61a605d68a Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Tue, 5 Oct 2021 17:54:36 -0500
Subject: [PATCH 18/38] Delete readme.md
---
Catalog Client Script/MRVS Unique Data selection/readme.md | 7 -------
1 file changed, 7 deletions(-)
delete mode 100644 Catalog Client Script/MRVS Unique Data selection/readme.md
diff --git a/Catalog Client Script/MRVS Unique Data selection/readme.md b/Catalog Client Script/MRVS Unique Data selection/readme.md
deleted file mode 100644
index 9c5906421e..0000000000
--- a/Catalog Client Script/MRVS Unique Data selection/readme.md
+++ /dev/null
@@ -1,7 +0,0 @@
-# Prevent data selection form MRVS variable
-There are plenty of ways to do this and Queubec servicenow did introduce a new field called Unique (Checkbox) on the MRVS variable, but it works only on Service Portal and Agent workspace view and you cannot set your own message. If you would like to have your own message then you can go with this script.
-
-[Click here for ServiceNow Docs](https://docs.servicenow.com/bundle/quebec-servicenow-platform/page/product/service-catalog-management/task/t_CreateAVariableForACatalogItem.html)
-
-[Click here for script](script.js)
-
From abb8ce6f807d43ed894fc812b7bbd79a42c1e66a Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Tue, 5 Oct 2021 17:55:06 -0500
Subject: [PATCH 19/38] Delete script.js
---
.../MRVS Unique Data selection/script.js | 24 -------------------
1 file changed, 24 deletions(-)
delete mode 100644 Catalog Client Script/MRVS Unique Data selection/script.js
diff --git a/Catalog Client Script/MRVS Unique Data selection/script.js b/Catalog Client Script/MRVS Unique Data selection/script.js
deleted file mode 100644
index 394f489998..0000000000
--- a/Catalog Client Script/MRVS Unique Data selection/script.js
+++ /dev/null
@@ -1,24 +0,0 @@
-//On Change of MRVS reference variable name on which you need to set the unique data selection
-
-function onChange(control, oldValue, newValue, isLoading) {
- if (isLoading || newValue == '') {
- return;
- }
-
- var MRVS_FIELD = "field_name_here"; // Multi Row Variable set name
-
- var MRVS = (g_service_catalog.parent.getValue(MRVS_FIELD).length != 0) ? JSON.parse(g_service_catalog.parent.getValue(MRVS_FIELD)) : [];
-
- //If the MRVS is empty - exit
- if(MRVS.length == 0)return;
-
- var valueExists = MRVS.some(function(obj){
- return obj.reference_variable_name == newValue; //Reference Variable name which you need to make unique data selection
- });
-
- if(valueExists){
- g_form.showFieldMsg(MRVS_FIELD , "Field must be unique");
- }
-
-
-}
From 79f9164c00b1a8bd2d3edc5a7211ada01d76c9d1 Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Wed, 6 Oct 2021 16:13:36 -0500
Subject: [PATCH 20/38] Create script.js
---
.../script.js | 22 +++++++++++++++++++
1 file changed, 22 insertions(+)
create mode 100644 Catalog Client Script/Prevent duplicate records on MRVS/script.js
diff --git a/Catalog Client Script/Prevent duplicate records on MRVS/script.js b/Catalog Client Script/Prevent duplicate records on MRVS/script.js
new file mode 100644
index 0000000000..2a37e9f988
--- /dev/null
+++ b/Catalog Client Script/Prevent duplicate records on MRVS/script.js
@@ -0,0 +1,22 @@
+function onChange(control, oldValue, newValue, isLoading) {
+ if (isLoading || newValue == '') {
+ return;
+ }
+
+ var MRVS_FIELD = "field_name_here"; //Multi row variable set name
+
+ var MRVS = (g_service_catalog.parent.getValue(MRVS_FIELD).length != 0) ? JSON.parse(g_service_catalog.parent.getValue(MRVS_FIELD)) : [];
+
+ //If the MRVS is empty - exit
+ if(MRVS.length == 0)return;
+
+ var valueExists = MRVS.some(function(obj){
+ return obj.Variable_Name == newValue; // Reference variable name which needs to be unique
+ });
+
+ if(valueExists){
+ g_form.showFieldMsg(MRVS_FIELD , "Field must be unique");
+ }
+
+
+}
From cbf87b2d25290a10380701815a30009a318b5abc Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Wed, 6 Oct 2021 16:25:44 -0500
Subject: [PATCH 21/38] Create readme.md
---
.../Prevent duplicate records on MRVS/readme.md | 8 ++++++++
1 file changed, 8 insertions(+)
create mode 100644 Catalog Client Script/Prevent duplicate records on MRVS/readme.md
diff --git a/Catalog Client Script/Prevent duplicate records on MRVS/readme.md b/Catalog Client Script/Prevent duplicate records on MRVS/readme.md
new file mode 100644
index 0000000000..75db25ca07
--- /dev/null
+++ b/Catalog Client Script/Prevent duplicate records on MRVS/readme.md
@@ -0,0 +1,8 @@
+# Prevent duplicate records to be selected in Multi row variable set
+
+We have many ways to do this but this is bit unique compare to what you find in community, you can do it in one single script within the Variable set.
+Of course ServiceNow introduce a new feature in Quebec and have Unique checkbox field introuduced but to have a custom info message you need to go with the custom script.
+
+ [ServiceNow Docs to disallow duplicate values](https://docs.servicenow.com/bundle/quebec-servicenow-platform/page/product/service-catalog-management/task/t_CreateAVariableForACatalogItem.html)
+
+ [Click here for the script](script.js)
From 887f5cf536ad77823770a817c290de28a95c6548 Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Thu, 7 Oct 2021 14:11:17 -0500
Subject: [PATCH 22/38] Delete readme.md
---
.../Prevent duplicate records on MRVS/readme.md | 8 --------
1 file changed, 8 deletions(-)
delete mode 100644 Catalog Client Script/Prevent duplicate records on MRVS/readme.md
diff --git a/Catalog Client Script/Prevent duplicate records on MRVS/readme.md b/Catalog Client Script/Prevent duplicate records on MRVS/readme.md
deleted file mode 100644
index 75db25ca07..0000000000
--- a/Catalog Client Script/Prevent duplicate records on MRVS/readme.md
+++ /dev/null
@@ -1,8 +0,0 @@
-# Prevent duplicate records to be selected in Multi row variable set
-
-We have many ways to do this but this is bit unique compare to what you find in community, you can do it in one single script within the Variable set.
-Of course ServiceNow introduce a new feature in Quebec and have Unique checkbox field introuduced but to have a custom info message you need to go with the custom script.
-
- [ServiceNow Docs to disallow duplicate values](https://docs.servicenow.com/bundle/quebec-servicenow-platform/page/product/service-catalog-management/task/t_CreateAVariableForACatalogItem.html)
-
- [Click here for the script](script.js)
From 95f71a66096455041c3c9a676a90843a23b80370 Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Thu, 7 Oct 2021 14:11:44 -0500
Subject: [PATCH 23/38] Delete script.js
---
.../script.js | 22 -------------------
1 file changed, 22 deletions(-)
delete mode 100644 Catalog Client Script/Prevent duplicate records on MRVS/script.js
diff --git a/Catalog Client Script/Prevent duplicate records on MRVS/script.js b/Catalog Client Script/Prevent duplicate records on MRVS/script.js
deleted file mode 100644
index 2a37e9f988..0000000000
--- a/Catalog Client Script/Prevent duplicate records on MRVS/script.js
+++ /dev/null
@@ -1,22 +0,0 @@
-function onChange(control, oldValue, newValue, isLoading) {
- if (isLoading || newValue == '') {
- return;
- }
-
- var MRVS_FIELD = "field_name_here"; //Multi row variable set name
-
- var MRVS = (g_service_catalog.parent.getValue(MRVS_FIELD).length != 0) ? JSON.parse(g_service_catalog.parent.getValue(MRVS_FIELD)) : [];
-
- //If the MRVS is empty - exit
- if(MRVS.length == 0)return;
-
- var valueExists = MRVS.some(function(obj){
- return obj.Variable_Name == newValue; // Reference variable name which needs to be unique
- });
-
- if(valueExists){
- g_form.showFieldMsg(MRVS_FIELD , "Field must be unique");
- }
-
-
-}
From 1aabb482f85d0a6b4c30493af6b5860a86f0107d Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Thu, 7 Oct 2021 16:53:28 -0500
Subject: [PATCH 24/38] Create script.js
---
Catalog Client Script/script.js | 8 ++++++++
1 file changed, 8 insertions(+)
create mode 100644 Catalog Client Script/script.js
diff --git a/Catalog Client Script/script.js b/Catalog Client Script/script.js
new file mode 100644
index 0000000000..212534f590
--- /dev/null
+++ b/Catalog Client Script/script.js
@@ -0,0 +1,8 @@
+function onLoad() {
+//Type appropriate comment here, and begin script below
+
+var glideURL = new GlideURL();
+glideURL.setFromCurrent();
+var id = glideURL.getParam("sysparm_id"); // provide the parameter name
+
+}
From 56c1ded35d6deb1ac11833356999fd37da0891a1 Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Thu, 7 Oct 2021 16:54:06 -0500
Subject: [PATCH 25/38] Delete script.js
---
Catalog Client Script/script.js | 8 --------
1 file changed, 8 deletions(-)
delete mode 100644 Catalog Client Script/script.js
diff --git a/Catalog Client Script/script.js b/Catalog Client Script/script.js
deleted file mode 100644
index 212534f590..0000000000
--- a/Catalog Client Script/script.js
+++ /dev/null
@@ -1,8 +0,0 @@
-function onLoad() {
-//Type appropriate comment here, and begin script below
-
-var glideURL = new GlideURL();
-glideURL.setFromCurrent();
-var id = glideURL.getParam("sysparm_id"); // provide the parameter name
-
-}
From 9cb8f8619a1fa4804c90173624192f8ed8f70b59 Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Thu, 7 Oct 2021 16:54:54 -0500
Subject: [PATCH 26/38] Create script.js
---
Catalog Client Script/Get URL Parameters/script.js | 8 ++++++++
1 file changed, 8 insertions(+)
create mode 100644 Catalog Client Script/Get URL Parameters/script.js
diff --git a/Catalog Client Script/Get URL Parameters/script.js b/Catalog Client Script/Get URL Parameters/script.js
new file mode 100644
index 0000000000..212534f590
--- /dev/null
+++ b/Catalog Client Script/Get URL Parameters/script.js
@@ -0,0 +1,8 @@
+function onLoad() {
+//Type appropriate comment here, and begin script below
+
+var glideURL = new GlideURL();
+glideURL.setFromCurrent();
+var id = glideURL.getParam("sysparm_id"); // provide the parameter name
+
+}
From 509d847018f6d5b20ad59bea1c4132a18e3ca2ea Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Thu, 7 Oct 2021 16:59:00 -0500
Subject: [PATCH 27/38] Create readme.md
---
Catalog Client Script/Get URL Parameters/readme.md | 5 +++++
1 file changed, 5 insertions(+)
create mode 100644 Catalog Client Script/Get URL Parameters/readme.md
diff --git a/Catalog Client Script/Get URL Parameters/readme.md b/Catalog Client Script/Get URL Parameters/readme.md
new file mode 100644
index 0000000000..4d00b47e7c
--- /dev/null
+++ b/Catalog Client Script/Get URL Parameters/readme.md
@@ -0,0 +1,5 @@
+# Get URL Parameters in Global,Scoped Application for Record & Catalog Item
+
+There is many ways to grab url parameters into a client script or service portal. This is script is compatable for Global and Scoped application and works on Native UI and service portal.
+
+[Click here for the script](script.js)
From 5e3717315d09ba41806831b59bcf540995013ed8 Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Thu, 7 Oct 2021 16:59:16 -0500
Subject: [PATCH 28/38] Update readme.md
---
Catalog Client Script/Get URL Parameters/readme.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Catalog Client Script/Get URL Parameters/readme.md b/Catalog Client Script/Get URL Parameters/readme.md
index 4d00b47e7c..470cd79b69 100644
--- a/Catalog Client Script/Get URL Parameters/readme.md
+++ b/Catalog Client Script/Get URL Parameters/readme.md
@@ -1,5 +1,5 @@
# Get URL Parameters in Global,Scoped Application for Record & Catalog Item
-There is many ways to grab url parameters into a client script or service portal. This is script is compatable for Global and Scoped application and works on Native UI and service portal.
+There are many ways to grab url parameters into a client script or service portal. This is script is compatable for Global and Scoped application and works on Native UI and service portal.
[Click here for the script](script.js)
From 9e9c62740d23f82bfef2e2f8f4446427ab9cb899 Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Fri, 8 Oct 2021 16:38:23 -0500
Subject: [PATCH 29/38] Update script.js
---
Catalog Client Script/Get URL Parameters/script.js | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/Catalog Client Script/Get URL Parameters/script.js b/Catalog Client Script/Get URL Parameters/script.js
index 212534f590..f7f492fe5e 100644
--- a/Catalog Client Script/Get URL Parameters/script.js
+++ b/Catalog Client Script/Get URL Parameters/script.js
@@ -1,8 +1,15 @@
function onLoad() {
//Type appropriate comment here, and begin script below
-
+
+if(window == null){ // For Service Portal
+var url = top.location.href;
+var value = new URLSearchParams(url).get('sysparm_id'); //provide the parameter name
+console.log(value);
+}
+else{ //For Native UI
var glideURL = new GlideURL();
glideURL.setFromCurrent();
var id = glideURL.getParam("sysparm_id"); // provide the parameter name
-
+console.log(id);
+}
}
From bc3ae5c5dd974bea37f88e0697ff0c8042b5428f Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Fri, 8 Oct 2021 16:40:05 -0500
Subject: [PATCH 30/38] Update readme.md
---
Catalog Client Script/Get URL Parameters/readme.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Catalog Client Script/Get URL Parameters/readme.md b/Catalog Client Script/Get URL Parameters/readme.md
index 470cd79b69..534ca0ae7e 100644
--- a/Catalog Client Script/Get URL Parameters/readme.md
+++ b/Catalog Client Script/Get URL Parameters/readme.md
@@ -1,5 +1,5 @@
# Get URL Parameters in Global,Scoped Application for Record & Catalog Item
-There are many ways to grab url parameters into a client script or service portal. This is script is compatable for Global and Scoped application and works on Native UI and service portal.
+Many times there is a need to grab parameters from URL. This could be required at table form load or catalog item load and either in Global scope or custom scope application when redirection happened. Given script will help you in achieving this:
[Click here for the script](script.js)
From b0a0f71ccde40430f8645834ca4b0da59789342f Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Tue, 12 Oct 2021 04:12:37 +0530
Subject: [PATCH 31/38] Create scripted_rest_api.js
---
.../scripted_rest_api.js | 14 ++++++++++++++
1 file changed, 14 insertions(+)
create mode 100644 Scripted Rest API/Retrieving all variables from RITM or SCTASK/scripted_rest_api.js
diff --git a/Scripted Rest API/Retrieving all variables from RITM or SCTASK/scripted_rest_api.js b/Scripted Rest API/Retrieving all variables from RITM or SCTASK/scripted_rest_api.js
new file mode 100644
index 0000000000..6ada1e9dae
--- /dev/null
+++ b/Scripted Rest API/Retrieving all variables from RITM or SCTASK/scripted_rest_api.js
@@ -0,0 +1,14 @@
+// Scripted REST Api
+
+(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
+
+ var taskId = decodeURI(request.pathParams.sys_id);
+ var result = [];
+ var varHandler = new CHVarUtils();
+ result = varHandler.getTaskVarsById(taskId);
+ if(!result)
+ return sn_ws_err.NotFoundError("No variables found, please ensure you are passing a valid ServiceNow task record System ID (sys_id)");
+
+ return result;
+
+})(request, response);
From 0e6c3b8292cd31863dbca56a17aedb53a46c8364 Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Tue, 12 Oct 2021 04:13:34 +0530
Subject: [PATCH 32/38] Create CHVarUtils_ScriptInclude.js
---
.../CHVarUtils_ScriptInclude.js | 107 ++++++++++++++++++
1 file changed, 107 insertions(+)
create mode 100644 Scripted Rest API/Retrieving all variables from RITM or SCTASK/CHVarUtils_ScriptInclude.js
diff --git a/Scripted Rest API/Retrieving all variables from RITM or SCTASK/CHVarUtils_ScriptInclude.js b/Scripted Rest API/Retrieving all variables from RITM or SCTASK/CHVarUtils_ScriptInclude.js
new file mode 100644
index 0000000000..b52067ac2d
--- /dev/null
+++ b/Scripted Rest API/Retrieving all variables from RITM or SCTASK/CHVarUtils_ScriptInclude.js
@@ -0,0 +1,107 @@
+var CHVarUtils = Class.create();
+CHVarUtils.prototype = {
+ initialize: function() {},
+ getTaskVarsById: function(taskId) {
+
+ //Given a System ID, find all variables and their internal and display values.
+ var resultJson = {};
+ var varArr = [];
+ var mrvArr = [];
+ var varCount = 0;
+ var mrvCount = 0;
+ var taskTable = "";
+ var info = "";
+
+ if (taskId) {
+
+ var ts = new GlideRecord("task");
+ ts.get("sys_id", taskId);
+
+ if (ts.sys_id) {
+ if (ts.sys_class_name) {
+ taskTable = ts.sys_class_name;
+
+ //Get regular variables for SCTASKs and RITMs
+ if (taskTable == "sc_req_item" || taskTable == "sc_task") {
+ var item = "";
+ var itemName = "";
+ var itemRec = "";
+
+ var ci = new GlideRecord(taskTable);
+ ci.get("sys_id", taskId);
+
+ if (taskTable == "sc_req_item") {
+ item = ci.cat_item.sys_id;
+ itemRec = ci.sys_id;
+ itemName = ci.cat_item.name;
+ } else {
+ item = ci.request_item.cat_item.sys_id;
+ itemRec = ci.request_item.sys_id;
+ itemName = ci.request_item.cat_item.name;
+ }
+
+ var vars = ci.variables.getElements(true);
+
+ for (var x = 0; x < vars.length; x++) {
+
+ var v = vars[x];
+
+ if (!v.isMultiRow()) {
+ info = v.toString();
+ var varData = {};
+ varData.name = v.getLabel();
+ varData.value = v.getValue();
+ varData.displayValue = v.getDisplayValue();
+ varCount += 1;
+ varArr.push(varData);
+ } else {
+ var mrVarTable = {};
+ mrVarTable.name = v.getLabel();
+ mrvCount += 1;
+ var rows = v.getRows();
+ mrVarTable.rowCount = rows.length;
+ var mrRowArr = [];
+ var mrRowCollection = [];
+
+ for (var j = 0; j < rows.length; j++) {
+ var mrRowData = [];
+ var cells = rows[j].getCells();
+ for (var k = 0; k < cells.length; k++) {
+ var mrCellData = {};
+ mrCellData.name = cells[k].getLabel();
+ mrCellData.value = cells[k].getCellValue();
+ mrCellData.displayValue = cells[k].getCellDisplayValue();
+ mrRowData.push(mrCellData);
+ }
+ mrRowCollection.push(mrRowData);
+ }
+ mrVarTable.rowCollection = mrRowCollection || "(no data)";
+
+ mrvArr.push(mrVarTable);
+
+ }
+
+ }
+
+ }
+ }
+
+ resultJson.taskId = taskId;
+ resultJson.taskNumber = ts.number;
+ resultJson.state = ts.state.getDisplayValue();
+ resultJson.stage = ts.stage.getDisplayValue();
+ resultJson.approval = ts.approval.getDisplayValue();
+ resultJson.taskType = taskTable;
+ resultJson.taskShortDescription = ts.short_description;
+ resultJson.additionalInfo = info;
+ resultJson.variableCount = varCount;
+ resultJson.multiRowVariableCount = mrvCount;
+ resultJson.variables = varArr;
+ resultJson.multiRowVariables = mrvArr;
+
+ return resultJson;
+ }
+ }
+ },
+ type: 'CHVarUtils'
+};
From e81d6666cad78332a70d2df589523895efcd6e3d Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Tue, 12 Oct 2021 04:15:35 +0530
Subject: [PATCH 33/38] Update scripted_rest_api.js
---
.../scripted_rest_api.js | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/Scripted Rest API/Retrieving all variables from RITM or SCTASK/scripted_rest_api.js b/Scripted Rest API/Retrieving all variables from RITM or SCTASK/scripted_rest_api.js
index 6ada1e9dae..e9c48aaa69 100644
--- a/Scripted Rest API/Retrieving all variables from RITM or SCTASK/scripted_rest_api.js
+++ b/Scripted Rest API/Retrieving all variables from RITM or SCTASK/scripted_rest_api.js
@@ -1,4 +1,10 @@
// Scripted REST Api
+/*
+HTTP Method: GET
+Relative Path: /request_item/{sys_id} (we added /request_item because we'll probably end up building something similar for record producers
+the script include we built is already set up to determine whether the provided sys_id is for a Request Item or a Catalog Task).
+
+*/
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
From 13586dfb069dba4ad3f4d35b6799908a5b2c8dd6 Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Tue, 12 Oct 2021 04:23:29 +0530
Subject: [PATCH 34/38] Create output.js
---
.../output.js | 275 ++++++++++++++++++
1 file changed, 275 insertions(+)
create mode 100644 Scripted Rest API/Retrieving all variables from RITM or SCTASK/output.js
diff --git a/Scripted Rest API/Retrieving all variables from RITM or SCTASK/output.js b/Scripted Rest API/Retrieving all variables from RITM or SCTASK/output.js
new file mode 100644
index 0000000000..f7fc110303
--- /dev/null
+++ b/Scripted Rest API/Retrieving all variables from RITM or SCTASK/output.js
@@ -0,0 +1,275 @@
+{
+ "result": {
+ "taskId": "6dea3cdeec974462a7e751f414235ec6",
+ "taskNumber": "RITM0106176",
+ "state": "Open",
+ "stage": null,
+ "approval": "Requested",
+ "taskType": "sc_req_item",
+ "taskShortDescription": "Request the creation, modification, or removal of a network firewall rule or AWS Security Group rule",
+ "additionalInfo": "Testing our RITM Variable API",
+ "variableCount": 4,
+ "multiRowVariableCount": 2,
+ "variables": [
+ {
+ "name": "Rule Type",
+ "value": "both",
+ "displayValue": "Both"
+ },
+ {
+ "name": "Application Group Impacted",
+ "value": "16de082f69ab40bd95999cb6d691e2ea",
+ "displayValue": "My Application"
+ },
+ {
+ "name": "Project or Effort",
+ "value": "API Testing",
+ "displayValue": "API Testing"
+ },
+ {
+ "name": "Description",
+ "value": "Testing our RITM Variable API",
+ "displayValue": "Testing our RITM Variable API"
+ }
+ ],
+ "multiRowVariables": [
+ {
+ "name": "AWS Security Group Rules",
+ "rowCount": 3,
+ "rowCollection": [
+ [
+ {
+ "name": "Action",
+ "value": "add",
+ "displayValue": "Add Rule"
+ },
+ {
+ "name": "Rule Type",
+ "value": "inbound",
+ "displayValue": "Inbound"
+ },
+ {
+ "name": "AWS Account",
+ "value": "some_account",
+ "displayValue": "Some Account"
+ },
+ {
+ "name": "Security Group",
+ "value": "sg-123456",
+ "displayValue": "sg-123456"
+ },
+ {
+ "name": "Protocol",
+ "value": "tcp",
+ "displayValue": "TCP"
+ },
+ {
+ "name": "IP Address",
+ "value": "100.100.100.1",
+ "displayValue": "100.100.100.1"
+ },
+ {
+ "name": "Port(s)",
+ "value": "500",
+ "displayValue": "500"
+ },
+ {
+ "name": "Temporary",
+ "value": "false",
+ "displayValue": "false"
+ },
+ {
+ "name": "Expiration Date",
+ "value": "",
+ "displayValue": ""
+ }
+ ],
+ [
+ {
+ "name": "Action",
+ "value": "add",
+ "displayValue": "Add Rule"
+ },
+ {
+ "name": "Rule Type",
+ "value": "outbound",
+ "displayValue": "Outbound"
+ },
+ {
+ "name": "AWS Account",
+ "value": "my_account",
+ "displayValue": "My Account"
+ },
+ {
+ "name": "Security Group",
+ "value": "sg-blahblahblah",
+ "displayValue": "sg-blahblahblah"
+ },
+ {
+ "name": "Protocol",
+ "value": "tcp",
+ "displayValue": "TCP"
+ },
+ {
+ "name": "IP Address",
+ "value": "200.200.100.1",
+ "displayValue": "200.200.100.1"
+ },
+ {
+ "name": "Port(s)",
+ "value": "500,600",
+ "displayValue": "500,600"
+ },
+ {
+ "name": "Temporary",
+ "value": "true",
+ "displayValue": "true"
+ },
+ {
+ "name": "Expiration Date",
+ "value": "2021-11-02",
+ "displayValue": "2021-11-02"
+ }
+ ],
+ [
+ {
+ "name": "Action",
+ "value": "remove",
+ "displayValue": "Remove Rule"
+ },
+ {
+ "name": "Rule Type",
+ "value": "inbound",
+ "displayValue": "Inbound"
+ },
+ {
+ "name": "AWS Account",
+ "value": "R & D",
+ "displayValue": "R & D"
+ },
+ {
+ "name": "Security Group",
+ "value": "sg-blahblahblah",
+ "displayValue": "sg-blahblahblah"
+ },
+ {
+ "name": "Protocol",
+ "value": "tcp",
+ "displayValue": "TCP"
+ },
+ {
+ "name": "IP Address",
+ "value": "200.100.100.3",
+ "displayValue": "200.100.100.3"
+ },
+ {
+ "name": "Port(s)",
+ "value": "89",
+ "displayValue": "89"
+ },
+ {
+ "name": "Temporary",
+ "value": "false",
+ "displayValue": "false"
+ },
+ {
+ "name": "Expiration Date",
+ "value": "",
+ "displayValue": ""
+ }
+ ]
+ ]
+ },
+ {
+ "name": "Firewall Rules",
+ "rowCount": 2,
+ "rowCollection": [
+ [
+ {
+ "name": "Action",
+ "value": "add",
+ "displayValue": "Add Rule"
+ },
+ {
+ "name": "Rule Type",
+ "value": "permit",
+ "displayValue": "Permit"
+ },
+ {
+ "name": "Protocol",
+ "value": "tcp",
+ "displayValue": "TCP"
+ },
+ {
+ "name": "Port(s)",
+ "value": "100",
+ "displayValue": "100"
+ },
+ {
+ "name": "Source IP Address",
+ "value": "100.100.100.1",
+ "displayValue": "100.100.100.1"
+ },
+ {
+ "name": "Destination IP Address",
+ "value": "100.200.100.2",
+ "displayValue": "100.200.100.2"
+ },
+ {
+ "name": "Temporary",
+ "value": "true",
+ "displayValue": "true"
+ },
+ {
+ "name": "Expiration Date",
+ "value": "2021-11-03",
+ "displayValue": "2021-11-03"
+ }
+ ],
+ [
+ {
+ "name": "Action",
+ "value": "add",
+ "displayValue": "Add Rule"
+ },
+ {
+ "name": "Rule Type",
+ "value": "permit",
+ "displayValue": "Permit"
+ },
+ {
+ "name": "Protocol",
+ "value": "tcp",
+ "displayValue": "TCP"
+ },
+ {
+ "name": "Port(s)",
+ "value": "80, 443",
+ "displayValue": "80, 443"
+ },
+ {
+ "name": "Source IP Address",
+ "value": "200.100.100.1",
+ "displayValue": "200.100.100.1"
+ },
+ {
+ "name": "Destination IP Address",
+ "value": "200.200.100.2",
+ "displayValue": "200.200.100.2"
+ },
+ {
+ "name": "Temporary",
+ "value": "false",
+ "displayValue": "false"
+ },
+ {
+ "name": "Expiration Date",
+ "value": "",
+ "displayValue": ""
+ }
+ ]
+ ]
+ }
+ ]
+ }
+}
From 2ef8ff0a4d0d2c9e6a16c85b187d4b80ce4cfe59 Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Tue, 12 Oct 2021 04:24:11 +0530
Subject: [PATCH 35/38] Create readme.md
---
.../readme.md | 8 ++++++++
1 file changed, 8 insertions(+)
create mode 100644 Scripted Rest API/Retrieving all variables from RITM or SCTASK/readme.md
diff --git a/Scripted Rest API/Retrieving all variables from RITM or SCTASK/readme.md b/Scripted Rest API/Retrieving all variables from RITM or SCTASK/readme.md
new file mode 100644
index 0000000000..1a68c85e86
--- /dev/null
+++ b/Scripted Rest API/Retrieving all variables from RITM or SCTASK/readme.md
@@ -0,0 +1,8 @@
+# Retrieve all variables (including multi-row) from any Request Item or Catalog Task - and push JSON for use in a Scripted REST API
+We can pull the variables easily not that hard to do using existing APIs, but if you want to pull a list of variables and their values, it gets a little messy. If you want values from a Multi-Row Variable Set, it gets even messier.
+So, we set about building a Scripted REST API our partners can use.
+So... here's our take on this..
+
+ 1. [Build a Scripted REST API. We set ours up with pretty generic settings as mentioned in the script comments](scripted_rest_api.js)
+ 2. [Build a script include (the one referenced in the resource script)](CHVarUtils_ScriptInclude.js)
+ 3. [output](output.js)
From 9fd906370e0afa5007546ba26f8fb4183b6fad09 Mon Sep 17 00:00:00 2001
From: azeezgaa <48519253+azeezgaa@users.noreply.github.com>
Date: Tue, 12 Oct 2021 04:27:44 +0530
Subject: [PATCH 36/38] Delete Scripted Rest API/Retrieving all variables from
RITM or SCTASK directory
---
.../CHVarUtils_ScriptInclude.js | 107 -------
.../output.js | 275 ------------------
.../readme.md | 8 -
.../scripted_rest_api.js | 20 --
4 files changed, 410 deletions(-)
delete mode 100644 Scripted Rest API/Retrieving all variables from RITM or SCTASK/CHVarUtils_ScriptInclude.js
delete mode 100644 Scripted Rest API/Retrieving all variables from RITM or SCTASK/output.js
delete mode 100644 Scripted Rest API/Retrieving all variables from RITM or SCTASK/readme.md
delete mode 100644 Scripted Rest API/Retrieving all variables from RITM or SCTASK/scripted_rest_api.js
diff --git a/Scripted Rest API/Retrieving all variables from RITM or SCTASK/CHVarUtils_ScriptInclude.js b/Scripted Rest API/Retrieving all variables from RITM or SCTASK/CHVarUtils_ScriptInclude.js
deleted file mode 100644
index b52067ac2d..0000000000
--- a/Scripted Rest API/Retrieving all variables from RITM or SCTASK/CHVarUtils_ScriptInclude.js
+++ /dev/null
@@ -1,107 +0,0 @@
-var CHVarUtils = Class.create();
-CHVarUtils.prototype = {
- initialize: function() {},
- getTaskVarsById: function(taskId) {
-
- //Given a System ID, find all variables and their internal and display values.
- var resultJson = {};
- var varArr = [];
- var mrvArr = [];
- var varCount = 0;
- var mrvCount = 0;
- var taskTable = "";
- var info = "";
-
- if (taskId) {
-
- var ts = new GlideRecord("task");
- ts.get("sys_id", taskId);
-
- if (ts.sys_id) {
- if (ts.sys_class_name) {
- taskTable = ts.sys_class_name;
-
- //Get regular variables for SCTASKs and RITMs
- if (taskTable == "sc_req_item" || taskTable == "sc_task") {
- var item = "";
- var itemName = "";
- var itemRec = "";
-
- var ci = new GlideRecord(taskTable);
- ci.get("sys_id", taskId);
-
- if (taskTable == "sc_req_item") {
- item = ci.cat_item.sys_id;
- itemRec = ci.sys_id;
- itemName = ci.cat_item.name;
- } else {
- item = ci.request_item.cat_item.sys_id;
- itemRec = ci.request_item.sys_id;
- itemName = ci.request_item.cat_item.name;
- }
-
- var vars = ci.variables.getElements(true);
-
- for (var x = 0; x < vars.length; x++) {
-
- var v = vars[x];
-
- if (!v.isMultiRow()) {
- info = v.toString();
- var varData = {};
- varData.name = v.getLabel();
- varData.value = v.getValue();
- varData.displayValue = v.getDisplayValue();
- varCount += 1;
- varArr.push(varData);
- } else {
- var mrVarTable = {};
- mrVarTable.name = v.getLabel();
- mrvCount += 1;
- var rows = v.getRows();
- mrVarTable.rowCount = rows.length;
- var mrRowArr = [];
- var mrRowCollection = [];
-
- for (var j = 0; j < rows.length; j++) {
- var mrRowData = [];
- var cells = rows[j].getCells();
- for (var k = 0; k < cells.length; k++) {
- var mrCellData = {};
- mrCellData.name = cells[k].getLabel();
- mrCellData.value = cells[k].getCellValue();
- mrCellData.displayValue = cells[k].getCellDisplayValue();
- mrRowData.push(mrCellData);
- }
- mrRowCollection.push(mrRowData);
- }
- mrVarTable.rowCollection = mrRowCollection || "(no data)";
-
- mrvArr.push(mrVarTable);
-
- }
-
- }
-
- }
- }
-
- resultJson.taskId = taskId;
- resultJson.taskNumber = ts.number;
- resultJson.state = ts.state.getDisplayValue();
- resultJson.stage = ts.stage.getDisplayValue();
- resultJson.approval = ts.approval.getDisplayValue();
- resultJson.taskType = taskTable;
- resultJson.taskShortDescription = ts.short_description;
- resultJson.additionalInfo = info;
- resultJson.variableCount = varCount;
- resultJson.multiRowVariableCount = mrvCount;
- resultJson.variables = varArr;
- resultJson.multiRowVariables = mrvArr;
-
- return resultJson;
- }
- }
- },
- type: 'CHVarUtils'
-};
diff --git a/Scripted Rest API/Retrieving all variables from RITM or SCTASK/output.js b/Scripted Rest API/Retrieving all variables from RITM or SCTASK/output.js
deleted file mode 100644
index f7fc110303..0000000000
--- a/Scripted Rest API/Retrieving all variables from RITM or SCTASK/output.js
+++ /dev/null
@@ -1,275 +0,0 @@
-{
- "result": {
- "taskId": "6dea3cdeec974462a7e751f414235ec6",
- "taskNumber": "RITM0106176",
- "state": "Open",
- "stage": null,
- "approval": "Requested",
- "taskType": "sc_req_item",
- "taskShortDescription": "Request the creation, modification, or removal of a network firewall rule or AWS Security Group rule",
- "additionalInfo": "Testing our RITM Variable API",
- "variableCount": 4,
- "multiRowVariableCount": 2,
- "variables": [
- {
- "name": "Rule Type",
- "value": "both",
- "displayValue": "Both"
- },
- {
- "name": "Application Group Impacted",
- "value": "16de082f69ab40bd95999cb6d691e2ea",
- "displayValue": "My Application"
- },
- {
- "name": "Project or Effort",
- "value": "API Testing",
- "displayValue": "API Testing"
- },
- {
- "name": "Description",
- "value": "Testing our RITM Variable API",
- "displayValue": "Testing our RITM Variable API"
- }
- ],
- "multiRowVariables": [
- {
- "name": "AWS Security Group Rules",
- "rowCount": 3,
- "rowCollection": [
- [
- {
- "name": "Action",
- "value": "add",
- "displayValue": "Add Rule"
- },
- {
- "name": "Rule Type",
- "value": "inbound",
- "displayValue": "Inbound"
- },
- {
- "name": "AWS Account",
- "value": "some_account",
- "displayValue": "Some Account"
- },
- {
- "name": "Security Group",
- "value": "sg-123456",
- "displayValue": "sg-123456"
- },
- {
- "name": "Protocol",
- "value": "tcp",
- "displayValue": "TCP"
- },
- {
- "name": "IP Address",
- "value": "100.100.100.1",
- "displayValue": "100.100.100.1"
- },
- {
- "name": "Port(s)",
- "value": "500",
- "displayValue": "500"
- },
- {
- "name": "Temporary",
- "value": "false",
- "displayValue": "false"
- },
- {
- "name": "Expiration Date",
- "value": "",
- "displayValue": ""
- }
- ],
- [
- {
- "name": "Action",
- "value": "add",
- "displayValue": "Add Rule"
- },
- {
- "name": "Rule Type",
- "value": "outbound",
- "displayValue": "Outbound"
- },
- {
- "name": "AWS Account",
- "value": "my_account",
- "displayValue": "My Account"
- },
- {
- "name": "Security Group",
- "value": "sg-blahblahblah",
- "displayValue": "sg-blahblahblah"
- },
- {
- "name": "Protocol",
- "value": "tcp",
- "displayValue": "TCP"
- },
- {
- "name": "IP Address",
- "value": "200.200.100.1",
- "displayValue": "200.200.100.1"
- },
- {
- "name": "Port(s)",
- "value": "500,600",
- "displayValue": "500,600"
- },
- {
- "name": "Temporary",
- "value": "true",
- "displayValue": "true"
- },
- {
- "name": "Expiration Date",
- "value": "2021-11-02",
- "displayValue": "2021-11-02"
- }
- ],
- [
- {
- "name": "Action",
- "value": "remove",
- "displayValue": "Remove Rule"
- },
- {
- "name": "Rule Type",
- "value": "inbound",
- "displayValue": "Inbound"
- },
- {
- "name": "AWS Account",
- "value": "R & D",
- "displayValue": "R & D"
- },
- {
- "name": "Security Group",
- "value": "sg-blahblahblah",
- "displayValue": "sg-blahblahblah"
- },
- {
- "name": "Protocol",
- "value": "tcp",
- "displayValue": "TCP"
- },
- {
- "name": "IP Address",
- "value": "200.100.100.3",
- "displayValue": "200.100.100.3"
- },
- {
- "name": "Port(s)",
- "value": "89",
- "displayValue": "89"
- },
- {
- "name": "Temporary",
- "value": "false",
- "displayValue": "false"
- },
- {
- "name": "Expiration Date",
- "value": "",
- "displayValue": ""
- }
- ]
- ]
- },
- {
- "name": "Firewall Rules",
- "rowCount": 2,
- "rowCollection": [
- [
- {
- "name": "Action",
- "value": "add",
- "displayValue": "Add Rule"
- },
- {
- "name": "Rule Type",
- "value": "permit",
- "displayValue": "Permit"
- },
- {
- "name": "Protocol",
- "value": "tcp",
- "displayValue": "TCP"
- },
- {
- "name": "Port(s)",
- "value": "100",
- "displayValue": "100"
- },
- {
- "name": "Source IP Address",
- "value": "100.100.100.1",
- "displayValue": "100.100.100.1"
- },
- {
- "name": "Destination IP Address",
- "value": "100.200.100.2",
- "displayValue": "100.200.100.2"
- },
- {
- "name": "Temporary",
- "value": "true",
- "displayValue": "true"
- },
- {
- "name": "Expiration Date",
- "value": "2021-11-03",
- "displayValue": "2021-11-03"
- }
- ],
- [
- {
- "name": "Action",
- "value": "add",
- "displayValue": "Add Rule"
- },
- {
- "name": "Rule Type",
- "value": "permit",
- "displayValue": "Permit"
- },
- {
- "name": "Protocol",
- "value": "tcp",
- "displayValue": "TCP"
- },
- {
- "name": "Port(s)",
- "value": "80, 443",
- "displayValue": "80, 443"
- },
- {
- "name": "Source IP Address",
- "value": "200.100.100.1",
- "displayValue": "200.100.100.1"
- },
- {
- "name": "Destination IP Address",
- "value": "200.200.100.2",
- "displayValue": "200.200.100.2"
- },
- {
- "name": "Temporary",
- "value": "false",
- "displayValue": "false"
- },
- {
- "name": "Expiration Date",
- "value": "",
- "displayValue": ""
- }
- ]
- ]
- }
- ]
- }
-}
diff --git a/Scripted Rest API/Retrieving all variables from RITM or SCTASK/readme.md b/Scripted Rest API/Retrieving all variables from RITM or SCTASK/readme.md
deleted file mode 100644
index 1a68c85e86..0000000000
--- a/Scripted Rest API/Retrieving all variables from RITM or SCTASK/readme.md
+++ /dev/null
@@ -1,8 +0,0 @@
-# Retrieve all variables (including multi-row) from any Request Item or Catalog Task - and push JSON for use in a Scripted REST API
-We can pull the variables easily not that hard to do using existing APIs, but if you want to pull a list of variables and their values, it gets a little messy. If you want values from a Multi-Row Variable Set, it gets even messier.
-So, we set about building a Scripted REST API our partners can use.
-So... here's our take on this..
-
- 1. [Build a Scripted REST API. We set ours up with pretty generic settings as mentioned in the script comments](scripted_rest_api.js)
- 2. [Build a script include (the one referenced in the resource script)](CHVarUtils_ScriptInclude.js)
- 3. [output](output.js)
diff --git a/Scripted Rest API/Retrieving all variables from RITM or SCTASK/scripted_rest_api.js b/Scripted Rest API/Retrieving all variables from RITM or SCTASK/scripted_rest_api.js
deleted file mode 100644
index e9c48aaa69..0000000000
--- a/Scripted Rest API/Retrieving all variables from RITM or SCTASK/scripted_rest_api.js
+++ /dev/null
@@ -1,20 +0,0 @@
-// Scripted REST Api
-/*
-HTTP Method: GET
-Relative Path: /request_item/{sys_id} (we added /request_item because we'll probably end up building something similar for record producers
-the script include we built is already set up to determine whether the provided sys_id is for a Request Item or a Catalog Task).
-
-*/
-
-(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
-
- var taskId = decodeURI(request.pathParams.sys_id);
- var result = [];
- var varHandler = new CHVarUtils();
- result = varHandler.getTaskVarsById(taskId);
- if(!result)
- return sn_ws_err.NotFoundError("No variables found, please ensure you are passing a valid ServiceNow task record System ID (sys_id)");
-
- return result;
-
-})(request, response);
From 52f0e5b5ae53654775fb877c641142af05ca67db Mon Sep 17 00:00:00 2001
From: Carleen Carter <40255402+smartcarleen@users.noreply.github.com>
Date: Wed, 13 Oct 2021 12:20:53 -0500
Subject: [PATCH 37/38] Rename Catalog Client Script/Get URL
Parameters/readme.md to Client Scripts/Get URL Parameters/readme.md
---
.../Get URL Parameters/readme.md | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename {Catalog Client Script => Client Scripts}/Get URL Parameters/readme.md (100%)
diff --git a/Catalog Client Script/Get URL Parameters/readme.md b/Client Scripts/Get URL Parameters/readme.md
similarity index 100%
rename from Catalog Client Script/Get URL Parameters/readme.md
rename to Client Scripts/Get URL Parameters/readme.md
From 5f6fa652b5c03d1cb3a1d60237d99b51059db72f Mon Sep 17 00:00:00 2001
From: Carleen Carter <40255402+smartcarleen@users.noreply.github.com>
Date: Wed, 13 Oct 2021 12:21:36 -0500
Subject: [PATCH 38/38] Rename Catalog Client Script/Get URL
Parameters/script.js to Client Scripts/Get URL Parameters/script.js
---
.../Get URL Parameters/script.js | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename {Catalog Client Script => Client Scripts}/Get URL Parameters/script.js (100%)
diff --git a/Catalog Client Script/Get URL Parameters/script.js b/Client Scripts/Get URL Parameters/script.js
similarity index 100%
rename from Catalog Client Script/Get URL Parameters/script.js
rename to Client Scripts/Get URL Parameters/script.js