how to add attachment excel record in servicenow using script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2024 03:04 AM
hello,
Urgent help need
I have a updated excel that i want to attach to attachment record using script because kb article is published.
var attachment = new GlideSysAttachment();
//set up inputs
var rec = new GlideRecord('kb_knowledge');
rec.get('sys_id');
var fileName = 'abc.xls';
var contentType = 'application/vnd.ms-excel';
var content = '';
var agr = attachment.write(rec, fileName, contentType,content);
gs.info('The attachment sys_id is: ' + agr);
Please accept the solution /mark this response as correct or helpful if it assisted you with your question.
Regards,
Animesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2024 06:10 AM
you cannot create excel file and write it to record. you can create csv file
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2024 03:30 AM
@Ankur Bawiskar
thanks for the reply, but it was working with custom data in the excel and the excel was attached to the record, but the problem is that i am not able to read the data from the excel in snow, if that may be possible with decode /encode method no idea,
Please accept the solution /mark this response as correct or helpful if it assisted you with your question.
Regards,
Animesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2024 03:50 AM
you want to read excel file?
if yes then you need to use GlideExcel parser
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader