create attachment record in knowledge table using script for type excel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2024 03:05 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 03:47 AM
hi @AnimeshP_96 ,
Please create Before update Business rule, and add the condition when Workflow changes to "Publish" then below script can be added
var attachment = new GlideSysAttachment();
var rec = new GlideRecord(current.sys_class_name);
rec.get(current.sys_id);
var fileName = 'example.txt';
var contentType = 'text/csv';
var content = 'The text that is stored inside my file';
var agr = attachment.write(rec, fileName, contentType, content);
gs.addErrorMessage('The attachment sys_id is: ' + agr);
Please mark helpful & correct answer if it's really worthy for you.
Thanks,
BK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2024 12:12 AM
@Bhavya11
i think you didnt get the context first you dont require a business rule for it because i just have to attach a file in the record., theni am working with excel data not csv, let me know if you have any other solutions for it.
Please accept the solution /mark this response as correct or helpful if it assisted you with your question.
Regards,
Animesh