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-01-2022 10:55 PM
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.
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 12:52 AM
Hi
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
Whether I'm doing something wrong?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2022 12:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2022 12:55 AM