- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2022 05:55 AM
Hi All,
I am creating an excel and attaching to a record.
I am using the below code to attach the file:
var grRec = new GlideRecord("sc_task");
grRec.addQuery("sys_id", current.sys_id + "");
grRec.query();
if (grRec.next()) {
var grAttachment = new GlideSysAttachment();
grAttachment.write(grRec, fileName, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', csvData);
}
It works perfectly for application/csv but not for xlsx format and I need the .xlsx format. The file gets created and attached but when I try to open it, it says the file is corrupted.
Could anyone tell me what am i doing wrong here, please?
Thanks!!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2022 06:51 AM
Hi,
it's not straight forward for xlsx file and it won't work
Either keep it csv or else you would require custom solution to create xlsx file and attach to record
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
‎01-27-2022 06:05 AM
hey
Could you guys please help?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2022 06:06 AM
Hi,
Please have a look at this ServiceNow KB article which might help you.
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0752391
Regards,
Ankita Sarkar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2022 06:13 AM
hey,
This is not a REST call.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2022 06:51 AM
Hi,
it's not straight forward for xlsx file and it won't work
Either keep it csv or else you would require custom solution to create xlsx file and attach to record
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader