The CreatorCon Call for Content is officially open! Get started here.

Attachment/Document retention time

azsnow
Giga Contributor

Hello SNOW community,

I would like to know the retention period for attachments added to a form or perhaps where to find it. Note: I have created a scoped app with a table extending Task. In case, this affects retention time.

I did some searching but most of it was tied to HR application.

Thank you!

1 ACCEPTED SOLUTION

Hi @azsnow 

As I had mentioned above, there isn't a retention period for attachments as far as when they will be purged. Using your scenario, that incident would still be there 5 years later with the attachment 🙂

If you delete the incident, the attachment is also deleted, just throwing that out there.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

7 REPLIES 7

Raj_Esh
Kilo Sage
Kilo Sage

 

Hello,

 

Attachments are stored in sys_attachment table and metadata in sys_attachment_doc

Please refer:

Attachments in ServiceNow

Administering attachments

 

Hope this helps.

 

Thanks,

Raj

--Raj

Hitoshi Ozawa
Giga Sage
Giga Sage

AFAIK, attachments should be retained without a set period.

There are 2 Scheduled Jobs to clean attachments:

 

Hitoshi Ozawa
Giga Sage
Giga Sage

Attachments can be deleted after a certain amount of time by creating a Scheduled Job.

Haven't tested but something like below in the scheduled job script.

var tableName = 'incident';
var grInc = new GlideRecord(tableName);
grInc.addEncodedQuery("sys_created_on<javascript:gs.beginningOfLastYear()");
grInc.query();
while(grInc .next()) {
  var attachment = new GlideSysAttachment();
  var agr = attachment.getAttachments(tableName, grInc.sys_id);
  while (agr.next()) {
    gs.info(agr.sys_id + " filename:" + agr.getValue('file_name'));
    attachment.deleteAttachment(agr.sys_id);
  }
}