GlideSysAttachment - Global
-
- UpdatedFeb 18, 2025
- 3 minutes to read
- Yokohama
- API reference
The GlideSysAttachment API provides methods for handling attachments.
Content is returned as a GlideScriptableInputStream object when getContentStream() is called. The GlideScriptableInputStream contains the actual bytes not converted into a string.
GlideSysAttachment - GlideSysAttachment()
Creates an instance of the GlideSysAttachment class.
Name | Type | Description |
---|---|---|
None |
GlideSysAttachment - copy(String sourceTable, String sourceID, String targetTable, String targetID)
Copies attachments from the source record to the target record.
Type | Description |
---|---|
String | Array of sys_ids of the attachments that were copied. |
Example
Output:
GlideSysAttachment - deleteAttachment(String attachmentID)
Deletes the specified attachment.
Name | Type | Description |
---|---|---|
attachmentID | String | Attachment's sys_id. |
Type | Description |
---|---|
void |
Example
GlideSysAttachment - getAttachments(String tableName, String sys_id)
Returns a GlideRecord containing the matching attachment metadata such as name, type, or size.
Name | Type | Description |
---|---|---|
tableName | String | Name of the table to which the attachment belongs; for example, incident. |
sys_id | String | Sys_id of record to which the attachment belongs. |
Type | Description |
---|---|
GlideRecord | GlideRecord object containing the matching attachment metadata such as name, type, or size. |
Example
The following script lists attachment file names for a record with two attachments.
Output:
GlideSysAttachment - getContentStream(String sysID)
Returns a GlideScriptableInputStream object given the sys_id of an attachment.
You can use the GlideTextReader API to read the content stream.
Name | Type | Description |
---|---|---|
sysID | String | Attachment sys_id. |
Type | Description |
---|---|
GlideScriptableInputStream | Stream that contains the attachment content. |
Example
Output:
GlideSysAttachment - write(GlideRecord record, String fileName, String contentType, String content)
Attaches a specified attachment to the specified record.
Type | Description |
---|---|
String | Attachment sys_id. Returns null if the attachment was not added. |
Example
Output:
GlideSysAttachment - writeContentStream(GlideRecord now_GR, String fileName, String contentType, GlideScriptableInputStream inputStream)
Inserts an attachment using the input stream.
Type | Description |
---|---|
String | Sys_id of the attachment created. |
Example
Attaches a content stream from the sys_attachment table to a test_table record.
On this page
- GlideSysAttachment - GlideSysAttachment()
- GlideSysAttachment - copy(String sourceTable, String sourceID, String targetTable, String targetID)
- GlideSysAttachment - deleteAttachment(String attachmentID)
- GlideSysAttachment - getAttachments(String tableName, String sys_id)
- GlideSysAttachment - getContentStream(String sysID)
- GlideSysAttachment - write(GlideRecord record, String fileName, String contentType, String content)
- GlideSysAttachment - writeContentStream(GlideRecord now_GR, String fileName, String contentType, GlideScriptableInputStream inputStream)