Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Parse the CSV attachment.

PK16
Tera Expert

Hello Community Experts,

I want to parse the CSV attachment and get the data present in that in the flow designer.

Is there any resources or script you have so that I can use them for reference?

(Note: I want to fetch the attachment from the sys_attachment table and parse it and display the values in the background script. After that, I will customize that in flow designer as well).

 

Regards,

PK

9 REPLIES 9

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

ServiceNow provided CSV Parser class which you can use in server side script.

In flow designer create a custom action and use that script.

CSVParser

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi @Ankur Bawiskar ,

I have created the below script:-  


try {
var attachment = new GlideSysAttachment();
var attachmentStream = attachment.getContentStream('1722a8da2fe5d1101a5cf3ecf699b65b');
var x = new sn_impex.CSVParser().parseLineToObject(attachmentStream);

gs.log('From CSV:'+x.title);


}
catch(ex) {
      gs.info("In Catch:"+ex.message);
}  

 

But it gives me output like below:-

it is not printing the title 

find_real_file.png

 

Whether I'm doing something wrong?

Thanks.

Below is my CSV file :-

find_real_file.png

Attachment :-

 

find_real_file.png