- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2022 09:30 PM
Hi,
Our need is to read content present in a Word attachment attached to a record and update the 'Comment' field with the content present in the Word attachment. The attachment may include images, the 'Comment' field is a HTML type field.
If this requirement has been done before, do share your views.
Used code to read values : https://gist.github.com/pmgupte/df835d6cdacf0345c2bc, but the variable returns 'unidentified'.
Thanks in advance!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2022 10:00 PM
check these links for alternative solution
Apache POI - the Java API for Microsoft Documents
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
‎03-01-2022 09:37 PM
Hi,
so can you share what script you tried; what debugging you performed?
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
‎03-01-2022 09:48 PM
var gr = new GlideRecord("table_name_here");
gr.addActiveQuery();
gr.query();
//gs.print('1 ' + gr.getClassDisplayValue());
while (gr.next()) {
var grAttch = new GlideRecord('sys_attachment');
grAttch.addQuery('table_sys_id', gr.sys_id); // get attcahments for current incident
grAttch.query();
if (grAttch.getRowCount() > 0) { //attachment exist
while (grAttch.next()) {
var sa = new GlideSysAttachment();
var dataInTextFile = sa.get(grAttch, 'attachment_name_here');
gs.print("Information Available in Text File: " + dataInTextFile);
var attachmentContents = sa.getContent(grAttch);
gs.print('Attach Content : ' + attachmentContents);
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2022 09:59 PM
Hi,
doc files are not simple text or csv file which can be read with getContent()
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
‎03-01-2022 10:00 PM
check these links for alternative solution
Apache POI - the Java API for Microsoft Documents
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader