Where are attachments saved for 'File Attachment' field type values?

Pranshu3
Tera Expert

When we have a 'File Attachment' type field in a table, and we attach a file in that table's form for that field; where are the attachments saved?

As in, in which table are the field's attachment records saved?

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Pranshu,

all attachments are stored in sys_attachment table and metadata for that attachment is stored in sys_attachment_doc

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

7 REPLIES 7

Omkar Mone
Mega Sage

Hi 

There is a table named sys_attachment where you will find the attachments.

 

Regards,

Omkar Mone

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Pranshu,

all attachments are stored in sys_attachment table and metadata for that attachment is stored in sys_attachment_doc

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

I am attaching some files directly to the record, and other files to file attachment fields, i found discovering these fields in the table to be a little different
To the Record:
Table name: x_my_table Table sys ID: sys_id_of_record_attachement_is_on
To the field: ZZ_YYx_my_table Table sys ID: sys_id_of_record_attachement_is_on

 

For whatever reason the way SN differentiates them is by adding a ZZ_YY to the table name, there may be more variations than this
if you have multiple attachment fields I suggest making sure you have a very unique file name, and searching by the to find how SN is changing that table name field for each one

ceskie
Kilo Guru

Hello Pranshu,

 once you upload an attachment in SNOW, a record(s) in two tables are created:

  1. sys_attachment
  2. sys_attachment_doc

Basically, (1) contains meta data about your attachment (from where it came, who created it, how large it is...) and the (2) table stores your actual attachment data split in 4K chunks, so if your attachemnt is larger, you will end with multiple records here. Also, important note, each record related to one particular attachment in sys_attachment_doc has its position (eg. first, second, third...), so your attachment can be retrieved in desired order once you query it.

See also https://snprotips.com/blog/2016/2/25/understanding-and-using-glideattachment for more details.