From b397f32337bce2f67738a3e50fdae77ae6c3b1a3 Mon Sep 17 00:00:00 2001 From: chaitanyalal18 <42643661+chaitanyalal18@users.noreply.github.com> Date: Wed, 15 Oct 2025 15:32:50 +0530 Subject: [PATCH 1/3] Create README.md Updating readme file with script functionality. --- .../Populate MRVS from Excel/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Server-Side Components/Script Includes/Populate MRVS from Excel/README.md diff --git a/Server-Side Components/Script Includes/Populate MRVS from Excel/README.md b/Server-Side Components/Script Includes/Populate MRVS from Excel/README.md new file mode 100644 index 0000000000..fd75a1818a --- /dev/null +++ b/Server-Side Components/Script Includes/Populate MRVS from Excel/README.md @@ -0,0 +1,16 @@ +This script allows to parse the excel file attached to the attachment variable and populate the MRVS present in the +catalog item / record producer. +Use this script in a client-callable script include along with an onChange client script on the attachment variable. + +When a file is uploaded as an attachment, it's metdata is stored in the sys_attachment table and sys_attachment_doc contains +the actual binary content. + +**getContentStream()** converts the binary content in a way so that it can be parsed by GlideExcelParser API. + +**Example used-** + +The excel has two columns "ID" and "Name" to store employee details. MRVS also has the same variable names. + + + + From 475910c7b875669a87a92fc8f651ea34fd95a7ed Mon Sep 17 00:00:00 2001 From: chaitanyalal18 <42643661+chaitanyalal18@users.noreply.github.com> Date: Fri, 17 Oct 2025 16:41:07 +0530 Subject: [PATCH 2/3] Create ParsingScript.js script to be used in script include --- .../Populate MRVS from Excel/ParsingScript.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Server-Side Components/Script Includes/Populate MRVS from Excel/ParsingScript.js diff --git a/Server-Side Components/Script Includes/Populate MRVS from Excel/ParsingScript.js b/Server-Side Components/Script Includes/Populate MRVS from Excel/ParsingScript.js new file mode 100644 index 0000000000..871e3747e9 --- /dev/null +++ b/Server-Side Components/Script Includes/Populate MRVS from Excel/ParsingScript.js @@ -0,0 +1,20 @@ +parseExcel: function() { + var attachSysId = this.getParameter('sysparm_id'); + var attachment = new GlideSysAttachment(); + var parser = new sn_impex.GlideExcelParser(); + var mrvsArray = []; + // get content of the attachment + var content = attachment.getContentStream(attachSysId); + parser.parse(content); + // Iterate through each row after header. Return false if row doesn't exist + while (parser.next()) { + // get content of the row + var row = parser.getRow(); + //push the object with key same as variable name in the MRVS. + var obj = {}; + obj.employee_id = row['Id']; + obj.employee_name = row['Name']; + mrvsArray.push(obj); + } + return JSON.stringify(mrvsArray); +}, From 8404b8f755652c722e2b06bf373448808fb8de09 Mon Sep 17 00:00:00 2001 From: chaitanyalal18 <42643661+chaitanyalal18@users.noreply.github.com> Date: Fri, 17 Oct 2025 16:42:34 +0530 Subject: [PATCH 3/3] Update README.md Script working details --- .../Script Includes/Populate MRVS from Excel/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Server-Side Components/Script Includes/Populate MRVS from Excel/README.md b/Server-Side Components/Script Includes/Populate MRVS from Excel/README.md index fd75a1818a..614e5a6b26 100644 --- a/Server-Side Components/Script Includes/Populate MRVS from Excel/README.md +++ b/Server-Side Components/Script Includes/Populate MRVS from Excel/README.md @@ -9,7 +9,7 @@ the actual binary content. **Example used-** -The excel has two columns "ID" and "Name" to store employee details. MRVS also has the same variable names. +The excel has two columns "Id" and "Name" to store employee details. MRVS also has the variable name as "employee_id" and "employee_name".