What This Table Is
The sys_attachment table stores metadata for every file attached to ServiceNow records. When users drag files onto forms or attach documents via email, this table captures the file name, size, content type, and relationship to the parent record. The actual binary file content lives in the sys_attachment_doc table, linked via the attachment's sys_id.
This table belongs to the Platform module and supports file attachment functionality across all ServiceNow applications. Unlike domain-specific tables, attachments can be linked to any record in any table through a flexible reference mechanism. The attachment system processes files uploaded through the web interface, mobile apps, email processing, and REST API calls.
The sys_attachment table doesn't extend any parent table and has no child tables extending it. Instead, it uses a polymorphic relationship pattern with table_name and table_sys_id fields to reference any record in the system. This design allows attachments to work uniformly across incidents, changes, knowledge articles, and custom applications.
Large enterprises typically see hundreds of thousands to millions of attachment records, with significant volume growth from email processing and mobile uploads. Each attachment record is small (under 1KB), but queries filtering by table_name and table_sys_id perform well due to compound indexing. Performance degrades when querying by file_name or content_type without including the table reference fields.
When You'll Script Against This Table
You'll script against sys_attachment in Business Rules when records are deleted (to clean up orphaned attachments), Script Includes for custom attachment processing, and Scheduled Jobs for attachment maintenance. Email processing scripts frequently query this table to handle inbound attachments. REST API integrations use it when uploading or retrieving file metadata.
The attachment_admin role controls full access, while itil provides read/write for most records. ACLs evaluate based on the parent record's permissions - users who can read an incident can typically read its attachments. Scoped applications inherit attachment access from their parent record permissions.
Common scripting patterns:
- Counting attachments on a record before allowing state changes
- Copying attachments when cloning or creating related records
- Filtering attachments by file type for processing workflows
- Building custom attachment viewers or download handlers
- Auditing attachment activity for compliance reporting
- Implementing custom file size or type restrictions
- Cleaning up attachments when parent records are archived
Table Gotchas
The table_name and table_sys_id fields are just strings with no foreign key constraints. ServiceNow won't prevent you from creating attachments pointing to non-existent records or invalid table names.
- The
statefield defaults to 'available' but can be 'pending' during upload or 'not_available' if processing fails
Deleting sys_attachment records doesn't automatically delete the corresponding sys_attachment_doc records, creating orphaned binary data that consumes storage.
- The
size_bytesfield stores the original file size, not the compressed storage size in the database - Queries without
table_namein the filter can trigger full table scans on large instances
The content_type field may not always match the actual file content - it's set from HTTP headers or file extensions, which can be spoofed or incorrect.
- ACL evaluation happens at query time based on parent record access, not when attachments are created
Enjoying this? Get one deep-dive per week.
Join 1,000+ ServiceNow pros — scripts, GlideRecord patterns, Flow Designer techniques, and career moves. Free.
Related Tables
The sys_attachment_doc table is the essential companion, storing the actual binary file content. Every sys_attachment record should have a corresponding sys_attachment_doc record with the same sys_id. The sys_email_attachment table references attachments created through email processing, linking them to specific email records.
Any table can have attachments through the polymorphic relationship, but task and its extensions (incident, change_request, problem) are the most common attachment targets. Knowledge base articles (kb_knowledge) and catalog items (sc_cat_item) also frequently store attachments.
When building reports or integrations, developers often join sys_attachment with parent tables to analyze attachment patterns by record type, urgency, or business category. The sys_user table connects through standard audit fields to track who uploaded attachments, while sys_audit provides detailed attachment creation and deletion history for compliance requirements.