Parse Excel to JSON format
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
I am trying to read an attachment file from a attachment variable to parse data in it and build a JSON payload to use that information on a variable. to make any progress , I cant get past the parser.parse line, not seeing any error too. testing below script in a fix script and then use it it in a client callable script include
var jsonData = [];
var attachmentSysId = '12f78a92938407509f98fa252603d6d6';
gs.info('AttachmentSysId--->' + attachmentSysId);
// Uses sn_impex namespace to parse attachment stream
var parser = new sn_impex.GlideExcelParser();
var attachmentStream = new GlideSysAttachment().getContentStream(attachmentSysId);
gs.info('AttachmentStream--->' + attachmentStream);
if (attachmentStream) {
gs.info('AttachmentStreamExists');
parser.parse(attachmentStream);
while (parser.next()) {
// Collects row data into the JSON array
gs.info('ParserExists');
jsonData.push(parser.getRow());
}
}
gs.info(JSON.stringify(jsonData));
Output:
*** Script: AttachmentSysId--->12f78a92938407509f98fa252603d6d6
*** Script: AttachmentStream--->com.glide.communications.GlideScriptableInputStream@74f0306d
*** Script: AttachmentStreamExists
*** Script: []
0 REPLIES 0
