How to fetch data from excel sheet and create payload when user upload excel sheet on catalog item form and order it

Saroj Patel
Tera Expert

find_real_file.png

when user will click on order then how to fetch data from that uploaded excel file .

 

 

After then have to create payload and send to third party.

4 REPLIES 4

Ravi Peddineni
Kilo Sage

Hi @Saroj Patel 

You can use Glide Excel Parser to read the data from excel and call third party api or application to send the data. Here is the Excel parser doc: https://developer.servicenow.com/dev.do#!/reference/api/quebec/server/GEPS-next

But how .. the file is not placing in sys_attachment table 

@Saroj Patel 

Where is that file getting saved when you attach it?

var parser = new sn_impex.GlideExcelParser(); 
var attachment = new GlideSysAttachment();
var attachmentStream = attachment.getContentStream('6d655d892f6601103b7d3e0ef699b627');
//sys id of excel file which is placed in sys_attachment table
parser.parse(attachmentStream); 
var arr=[];
var headers = parser.getColumnHeaders();  

while(parser.next()) { 
   var row = parser.getRow();
   var payload={};
   for(var i=0;i<headers.length;i++){
     payload[headers[i]]=row[headers[i]];
   }
gs.print(JSON.stringify(payload));
arr.push(JSON.stringify(payload));
}

gs.print(arr);
  

 

It is working fine and i am able to create payload from excel file