Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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);
},
Original file line number Diff line number Diff line change
@@ -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 variable name as "employee_id" and "employee_name".




Loading