Skip to main content

Archiving policies - junction object behaviour

How you can decide which related records, such as Content files, are archived

Alex Walter avatar
Written by Alex Walter
Updated this week

When creating an archiving policy, there is an advanced option of how to treat records attached via junction objects. Junction objects in Salesforce are a way of creating a "many-to-many" relationship. The most common example of these junction objects are ContentDocumentLinks, which are used for linking files to other standard records like Accounts, Cases, Contacts, etc. They are "many-to-many" as a file can be linked to many records, similarly a record like an Account can have many files attached to it.

When it comes to archiving data, if you do have a file linked to the record you are archiving, but this file is also attached to another record you want to keep, you need to make a decision. The two options are:

  1. Leave the file in Salesforce - just archive the record and the junction object record linking to the file.

  2. Archive the file along with any junction object record linking to the file.

Either of these can be appropriate depending on your needs. Below is a description of how to proceed with each of these options. We will detail each of the options with the help of an example.

Example

You are looking to archive a number of Case records that match a particular criteria. These Case records have files (Content Document) attached to them. These files are also attached to Contact records.

Here we have a Case: Old Case (to be archived), it has a file cogman, which is also attached to a Contact: Prof. Keep Around.

This is stored in Salesforce where the file is represented by ContentDocument and ContentVersion and linked to the Contact and Case by ContentDocumentLinks:

If we delete the Case, it will remove the ContentDocumentLink referencing it.

We then look at the options we have available.


1. Leave the file in Salesforce

This is the default option and it is the most common use case.

The Case record is archived, along with its ContentDocumentLink (colored red):

The file (ContentDocument and ContentVersion) are left in place:

The file remains on the Contact:

2. Archive the file along with any junction object record linking to the file.

This requires turning the toggle to the On state:

The Case record is archived, along with the following (all colored red):

  • The ContentDocumentLink from the Case to the file

  • The ContentDocument and ContentVersion for the file

  • The ContentDocumentLink linking the file to the Contact

All that remains is the Contact:

The file has been archived:

Notes

If the file is only attached to a single record that you are archiving, then this file will always be archived:

All these records are archived:

Please reach out in the chat if you have any further questions.

Did this answer your question?