- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2025 02:19 AM
Hello @fahabil698,
Firstly
Locate the Attachment Use the sys_attachment table to find the file.
var attachmentGR = new GlideRecord('sys_attachment');
attachmentGR.addQuery('table_name', 'your_table_name'); // e.g., 'incident'
attachmentGR.addQuery('table_sys_id', 'your_record_sys_id');
attachmentGR.query();
if (attachmentGR.next()) {
var attachmentSysId = attachmentGR.getValue('sys_id');
}
Read Attachment Content Use the GlideSysAttachment API
var gsa = new GlideSysAttachment();
var fileContent = gsa.getContentStream(attachmentGR);
var reader = new GlideTextReader(fileContent);
var text = '';
var line;
while ((line = reader.readLine()) != null) {
text += line + '\n';
}
gs.info(text); // Or process the content as needed