Parse the CSV attachment.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 10:19 PM
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
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2022 02:17 AM
Hi,
you should pass the header information as well
like this and then use parseLineToArray method and pass the header
var headers = ['Name','Email'];
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2022 11:07 PM
Hi
Please let me know if I'm doing something wrong in the below code :-
try {
var attachment = new GlideSysAttachment();
var headers = ['title', 'description', 'owner','order'];
var delimiter = ',';
var attachmentStream = attachment.getContentStream('1722a8da2fe5d1101a5cf3ecf699b65b');
var x = new sn_impex.CSVParser().parseLineToArray(attachmentStream,headers,delimiter);
gs.log('From CSV:'+x[0]);
}
catch(ex) {
gs.info("In Catch:"+ex.message);
}
Output:-
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2022 12:04 AM
Hi,
you use this to parse
try {
var attachment = new GlideSysAttachment();
var attachmentStream = attachment.getContentStream('1722a8da2fe5d1101a5cf3ecf699b65b');
// now parse each line
}
catch(ex) {
gs.info("In Catch:"+ex.message);
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2025 11:08 PM
Is there any solution to this question and if yes can someone please provide all the scenarios and steps to replicate this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2025 12:21 AM
Hi All,
Any solution for above question, even I'm trying to achieve similar thing.