Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Parse Excel to JSON format

monikagmk12
Mega Contributor

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: []

 

1 REPLY 1

k_lutz
Giga Sage

Hello,

 

Is the file in xlsx or another extension? Is this being done in the global scope or a scoped app?