You are here:
Create Archive Policies
To select specific records for archiving, define filters, schedule a process, and set data retention periods, create a policy in the Archive app.
Use the Archive policy wizard to define what objects to archive and when.
-
Go to the Policies tab and select New.
The New Policy window opens by default on the Archive Salesforce Data tab.
-
Click Next.
Note Complete all mandatory fields marked with an asterisk before proceeding to the next step.
-
In the Policy Details section, complete these fields.
- Policy Name: Descriptive name for the policy, such as Inactive Cases Older Than 2 Years.
- Description: Detailed description of the policy's function.
- Enabled: Runs the policy when saved. An active policy runs on its defined schedule.
- Clicks Next.
-
Define the policy scope and query logic.
- Root Object to Archive: The selection of the root object to archive
determines the hierarchy of related objects available later. Note To be available as a root object, the object supports
create(),delete(),describesObjects(),query(), andupdate()API calls. Big Objects aren't supported. - Query Mode: Specifies which root records to archive. These options are
available.
- Filter: Build query conditions by using the standard condition builder. Use the Field, Operator, and Value lists. Click +Add Condition to add criteria.
- Manual: Write a custom SOQL query in the editor. Use this mode for complex queries that the standard condition builder doesn't support.
- Record Limit: Maximum number of root records that this policy can archive
in a single run. The limit is 2,000,000 records. Note The total number of archived records, including children, can exceed this limit. To archive more than 2,000,000 root records daily, create multiple policies with the same SOQL criteria and schedule them to run at different times.
- Archive Related Files and Attachments: Archives all files and attachments
associated with the root record.
Important Archiving a file breaks any links that it has with other active records. Archive safely stores the file. The file remains accessible from the archived record's widget, but the file is no longer visible on the active records.
- Data Protected For: Total number of days to prevent newly created or updated records from being archived. The default is 90 days.
- Root Object to Archive: The selection of the root object to archive
determines the hierarchy of related objects available later.
-
Optionally, click Show Preview to view a sample of 10
records that match your scope.
Note Records excluded by the Data Protected For setting don't appear in the preview.
- Click Next.
-
Select the Root Object Archive Hierarchy. These options are available.
- Custom Selection: Expands the hierarchy and includes specific related
objects.
- Auto-Archived Object: Objects with a master-detail or restricted lookup relationship are automatically included and can't be deselected.
- Available Object: Includes the available object in the archive.
- Locked Relationship: Indicates a non-editable master-detail or
restricted lookup.
Note Selecting a lookup object archives only that object, not its children, unless you explicitly select them. If you deselect a root object, its child objects are automatically deselected to prevent orphaned records.
- Complete Hierarchy: Archives the root object and all descendant objects.
Note This option removes the root object and all descendant records from active storage. Make sure that you intend to remove the entire data hierarchy from your live environment.
- Custom Selection: Expands the hierarchy and includes specific related
objects.
- Click Next.
-
Configure Schedule, Retention, and Advanced Settings.
- Policy Schedule (UTC): Sets the frequency, day, and time.
- Retention Period: Defines the minimum time to retain archived data.
The minimum time is 1 month. The maximum time is 99 years and 11 months. A
setting of 0 years and 0 months makes data eligible for purging
within 24 hours.
Note Editing the retention period on an existing policy affects all records previously archived by that policy. To apply a new retention period only to future archived records, create a policy.
- These advanced settings are optional.
- Enable Boosting: Runs up to eight parallel activities per policy.
- Log Failures and Continue: If errors occur, logs individual deletion failures instead of rolling back the entire transaction. Select this option if your archive jobs involve root records with more than 800 related objects. For more information, see Log Failures and Continue.
-
Save your work.
If the Enabled option is turned on, the policy runs at the next scheduled time.
- Related Object Selection
Your Salesforce data forms a complex hierarchy. Accounts have Contacts, Contacts have Tasks, and Tasks have their own related records. To archive root records and their relationships up to 25 levels deep, use Related Object Selection in the Archive app. - Log Failures and Continue
During the archive process, the Archive app uses a single transaction to delete a root record with 800 or fewer related child records as an "all-or-nothing" operation. If an archive job fails to delete a single related child record due to a validation rule, the entire transaction rolls back. The Log Failures and Continue setting processes root records with more than 800 related child records. This setting breaks deletion into batches, logs individual record failures, and processes the rest of the archive job without rolling back the entire transaction. - SOQL Manual Query Mode
Use SOQL to define complex criteria for your archive policies when using Manual Query mode in the Archive app. - Archive ContentDocuments
ContentDocuments are files that can be archived as a root object or with a root record in the Archive app. Consider how each method aligns with your archiving strategy and data relationships before proceeding. - Archive ActivityFieldHistory
Track changes made to specific fields on Activity records, such as Tasks and Events. The ActivityFieldHistory feature shows what Archive app record was modified, the time and date when it was modified, and who made the change. - Apply Parent Object Filters to Archive ContentDocuments
Archive ContentDocument records in the Archive app by using filtering criteria based on root objects. - Configure Lookup Fields and Archiving Criteria
Create lookup fields and apply archiving criteria to your Archive app ContentDocuments. - Archive EmailMessages with Related Tasks
Archive all EmailMessages and their associated Tasks in the Archive app with the Archive EmailMessages with Related Tasks setting, or by archiving the Task as a root record. - Archive Digital Signatures in Field Service Lightning
When applying Digital Signatures in the Archive app, the Service Appointment, Work Order, and Work Order Line Item use cases require special attention. - Archive Archived Records in Salesforce
Archive records previously archived in your org, including events and closed tasks over 365 days old. If the new policy configuration window isn't turned on, you can manually add a specific clause to your query in the Archive app. - Archive nCino Objects
The Archive app can archive files related to specific Loans, Relationships, Collateral Management and other root records from Document Manager. The root record remains in your org while all root records are archived. - Same Root and Child Filter
Automatically exclude root records from a dataset when they have children of the same object type. This filter addresses a specific limitation in Salesforce Object Query Language (SOQL) and enables more advanced filtering of hierarchical data in the Archive app. - Enable Archiving of Objects with Missing Relationship Names
When archiving related records, the Archive app typically relies on defined relationship names to navigate root-child relationships. These relationship names are used in subqueries to identify and retrieve child records associated with a root record. However, some objects don't expose relationship names in the metadata, which can limit or block the archiving process for those object types. To archive these objects, use the Enable Archiving of Objects with Missing Relationship Names setting and then filterContentLocationby any external content references.
Log Failures and Continue
During the archive process, the Archive app uses a single transaction to delete a root record with 800 or fewer related child records as an "all-or-nothing" operation. If an archive job fails to delete a single related child record due to a validation rule, the entire transaction rolls back. The Log Failures and Continue setting processes root records with more than 800 related child records. This setting breaks deletion into batches, logs individual record failures, and processes the rest of the archive job without rolling back the entire transaction.
To activate this setting, go to Schedule, Retention, and Advanced Settings in the Archive policy wizard. In the Advanced section, check Log Failures and Continue.
Single Transaction Mode vs. Batch Mode
The Archive app handles deletions differently based on the volume of related child records.
Root records with 800 or fewer related child records attached to a specific root record use Single Transaction mode. A single "all-or-nothing" API request deletes the root record and its related child records. If one record fails, the whole transaction rolls back. The Log Failures and Continue setting doesn't apply.
Root records with more than 800 related child records use Batch mode. The root records and its related child records are split into smaller batches before deletion. If a related child record in the first batch fails, the entire transaction is canceled. In subsequent batches, if a related child record fails, Archive logs it, skips it, and continues the process. This action creates a live duplicate in your org.
Data Integrity and Trade-Offs
While this setting prioritizes archive job completion, it creates the risk of a successfully archived record remaining live. The system then identifies the live duplicate record and automatically excludes it from future archive jobs. Log Failures and Continue also provides a Download Duplicate Records CSV report of all archive records from Reports on the Archive home page. Review these reports to identify these types of duplicates.
- Lookup Child Record Duplicates: One or more related records, such as a Task, are archived but aren't deleted from your org.
- Root Record Duplicates: The root record, such as Case, and some of its related records are archived but aren't deleted from your org.
If you don't turn on the Log Failures and Continue setting, the archive job stops because the related Activity child record count exceeds 800. Archive doesn't archive the Case root record, and it doesn't delete any records.
If you turn on the Log Failures and Continue setting, and one related Activity child record isn't archived because of a custom validation rule, Archive logs the single failure and skips deleting that related Activity child record. The archive process deletes the remaining related Activity child records that don't conflict with custom validation rules. Archive successfully archives the Case root record. Any remaining related Activity child records that Archive doesn't delete remain live duplicate records. The system logs these records in the Duplicate Lookup Record report.
SOQL Manual Query Mode
Use SOQL to define complex criteria for your archive policies when using Manual Query mode in the Archive app.
Archiving Based on Related Objects
In Manual Query mode, you can archive records based on criteria found in a related object. This mode is useful when the criteria for archiving aren't on the root object itself, but on a root record.
Example: Archive Tasks Related to Closed Cases
This SQL example demonstrates how to archive Task records that are associated with
closed Case records. This query selects Task IDs where the WhatId
matches the ID of a Case with a Closed status.
SELECT Id FROM Task WHERE WhatId IN (SELECT Id FROM Case WHERE Status='Closed')Important Considerations
- Make sure your query always selects the
Idfield of the root object. - Complex queries using sub-selects aren't supported in the standard Condition Builder and must be entered manually in the SOQL Query editor.
Archive ContentDocuments
ContentDocuments are files that can be archived as a root object or with a root record in the Archive app. Consider how each method aligns with your archiving strategy and data relationships before proceeding.
Archive ContentDocument as a Root Object
Choose this method when a ContentDocument is a standalone entity or linked to multiple root records. For example, if a legal template is linked to many different Cases, you can preserve the ContentDocument's relationships with all these linked root records by archiving it as a root object.
ContentDocuments can be archived on their own schedule, regardless of the status of its linked records.
Important Considerations
- ContentDocument Links (CDLs), which connect ContentDocuments to root records, are archived along with the ContentDocuments.
- As CDLs remain preserved, archived ContentDocuments can still be found via Archive Search.
- You can specify which ContentDocuments to archive. For example, you can create a policy to archive all ContentDocuments related to the Case object that haven't been modified in 5 years.
You create a policy to archive Project Plan Q1 as a root object.
Project Plan Q1 is archived. The archived record shows Project Plan Q1 was historically linked to both Case-101 and Opportunity-ABC, but Project Plan Q1 no longer appears in the Files list on Case-101 and Opportunity-ABC, which are still live in your org. The relationship history of the ContentDocument is intact within the archive.
You create a policy to archive ABC Corp Account and select the Archive Related ContentDocuments option.
ABC Corp Account is archived. The Archive policy automatically finds and archives the related Service Agreement file from the Case. The ContentDocument and the Account remain linked in the archive.
Exclude ContentDocuments with Non-Archived Parents
When you want to archive a root record and all its related ContentDocuments but a related ContentDocument is linked to other root records in your org, this setting prevents you from archiving the ContentDocument.
When the setting is turned on, the system runs a safety check before archiving a ContentDocument. If a ContentDocument is related to any active root record in your org, it doesn't get archived with the root record being processed.
Closed Lost and Opportunity B with a Status of
Active. Opportunity A is ready to be archived. Opportunity B
remains active.You run an archive policy to archive Opportunity A.
The system inspects Sales Presentation and sees that it's also linked to Opportunity B, which isn't being archived. Because one of its related root records is active, the Archive policy skips the ContentDocument. Sales Presentation remains live in Salesforce and is correctly linked to Opportunity B, preventing data loss.
Opportunity A is archived without the ContentDocument. When Opportunity B is archived, it automatically archives the ContentDocument.
Archive ActivityFieldHistory
Track changes made to specific fields on Activity records, such as Tasks and Events. The ActivityFieldHistory feature shows what Archive app record was modified, the time and date when it was modified, and who made the change.
Why Salesforce Support Is Required
Controlled Access and Availability
- ActivityFieldHistory isn't on by default in all orgs. Support reviews your setup to establish compatibility and compliance before activation.
- Support configures tracking to meet data protection requirements, establishing secure integration with Archive.
Data Security
- Salesforce uses strict security measures to protect detailed tracking information stored in ActivityFieldHistory.
- Salesforce Support verifies that appropriate access controls exist so only authorized users can archive historical activity data.
Enable ActivityFieldHistory
To enable ActivityFieldHistory for Archive, contact Salesforce Support.
After ActivityFieldHistory is enabled, it can take up to a few days for the object to be available for archiving. Availability depends on how much data is in the object and how long it takes for the system to process it.
Limitations:
- After archiving, ActivityFieldHistory records can't be unarchived.
- After archiving, the ActivityFieldHistory object can briefly appear in both Archive and Salesforce. This status is temporary. The record has been deleted in Salesforce, and the system completes the deletion asynchronously. This delay is normal and establishes data consistency across systems.
Apply Parent Object Filters to Archive ContentDocuments
Archive ContentDocument records in the Archive app by using filtering criteria based on root objects.
For example, you can archive files associated with Opportunities when the
opportunity stage is Closed Lost. You can use this business case
to archive specific files while retaining essential Opportunity records in the
system. Filtering by root objects also identifies duplicate records.
Before proceeding with archiving, it's essential to understand the distinction between ContentDocument and ContentVersion.
- ContentDocuments are created when a file is uploaded to Salesforce, reflecting the file's relationship to the root object.
- ContentVersion represents the specific version of a document. For more information, see Content Objects.
Query ContentDocuments by Root Record
Here's an example codeblock of how to retrieve a list of ContentDocument records linked to an Opportunity.
SELECT Id, ContentDocumentId, LinkedEntityId FROM ContentDocumentLink
WHERE LinkedEntityId IN (SELECT Id FROM Opportunity)You then extract ContentVersion record IDs for the related ContentDocument.
SELECT ContentDocumentId, Id FROM ContentVersionConfigure Lookup Fields and Archiving Criteria
Create lookup fields and apply archiving criteria to your Archive app ContentDocuments.
-
Create a lookup field on the ContentVersion object that references the root
object used for filtering. For example, the field name can be
ContentDocLookupOppty. -
Create a formula checkbox on the ContentVersion object that contains the
archiving criteria. For example, the checkbox could be called
OpptyClosedLostwith this formula.ISPICKVAL(ContentDocLookupOppty__r.StageName ,'Closed Lost') -
Use Salesforce Inspector, Workbench, or another third-party tool to update the
lookup field with the correct related records. You can extract the related
records with this query.
SELECT Id, ContentDocumentId, LinkedEntityId FROM ContentDocumentLink WHERE LinkedEntityId IN (SELECT Id FROM Opportunity)In this query,
LinkedEntityIdis the ID of the related root record. -
Match the
ContentDocumentIdwith the correspondingLinkedEntityIdand update the lookup field. We recommend using a spreadsheet to help with this data update.- Copy and paste your ContentDocumentLink query results in the highlighted
columns of the
ContentDocumentLinktab. - Copy and paste your ContentVersion query results in the highlighted
columns of the
ContentVersiontab. - The
ContentVersion_For_Upserttab is your output data sheet for upserting.You can download this specific sheet as a CSV file and import the records to your org.
Note Upsert field mapping must includeIdandContentDocLookupOppty.
- Copy and paste your ContentDocumentLink query results in the highlighted
columns of the
- To ensure that the lookup field populates in the future, you must create a flow that forces the field to continually update.
- To create the archive policy, select ContentDocuments as the object and configure the fields.
Here's an example query.
SELECT Id FROM ContentDocument WHERE Id IN (SELECT ContentDocumentId
FROM ContentVersion WHERE Formula_checkbox_API_Name = TRUE)Archive Digital Signatures in Field Service Lightning
When applying Digital Signatures in the Archive app, the Service Appointment, Work Order, and Work Order Line Item use cases require special attention.
-
Under Service Appointment, a Service Report is created as a child with an
In Progressstatus. - When the service has been provided and the customer signs the Service Report, a Digital Signature is added to the Service Appointment.
-
When the Service Report is complete, the ContentDocument of the finalized
report is generated and the Digital Signature is deleted.
The Service Report now has a
Completedstatus.Note Archiving the Service Appointment before the Service Report has aCompletedstatus isn't recommended because you can't finalize the process.If Service Appointments are archived before the document is finalized and then unarchived, Salesforce removes the Digital Signature file upon reinsertion for business logic reasons.
Archive Archived Records in Salesforce
Archive records previously archived in your org, including events and closed tasks over 365 days old. If the new policy configuration window isn't turned on, you can manually add a specific clause to your query in the Archive app.
Salesforce archives these activities.
- Events that ended more than 365 days ago.
- Closed tasks due more than 365 days ago.
- If there's no due date, closed tasks created more than 365 days ago.
Salesforce doesn't delete archived activities, but they can be deleted manually, or you can use Archive to delete them from both your org and Archive into AWS or Azure.
Important Considerations
- When you create or refresh a sandbox, archived activities aren't copied.
- You can view and interact with archived activities in exported data and in certain locations in Salesforce.
If the New Policy Configuration window to archive previously archived records isn't turned on, you must manually add this clause to the query.
WHERE IsDeleted=False AND IsArchived=True Limit XXXFor example, here's a standard archive policy query.
SELECT Id FROM Task WHERE Title=" LIMIT 10Now, manually add the query clause to the policy.
SELECT Id FROM Task WHERE Title =" AND IsDeleted=False AND IsArchived=True LIMIT 10.
Archive nCino Objects
The Archive app can archive files related to specific Loans, Relationships, Collateral Management and other root records from Document Manager. The root record remains in your org while all root records are archived.
You can create policies on these main Placeholder objects to be archived as Roots with all of their attached documents.
- Loan Placeholder [
LLC_LoanDocument] and its Document Store Infrastructure. - Relationship Placeholder [
LLC_BI__Account Document] and its Document Store Infrastructure. - Global Placeholder [
LLC_BI__ Document_Placeholder] used in Collateral Management, Deposits, and its Document Store Infrastructure.
As part of the policy, the underlying Document Manager infrastructure is archived together with the ContentDocument, such as driver's license, passport, and other financial transactions. Multiple versions of these documents are also archived.
Create a Policy
These steps apply to all three Placeholder objects.
In this scenario, these documents were uploaded under these Placeholders.
- Credit Memo
- Privacy Policy
- Term Sheet
- Generated Forms - 3 versions
- Go to the Policies tab arrow and select +New Policy.
- Select Archive Policy.
- Click Next.
-
In the Policy Information section, add values for these fields.
- Policy Name—Enter an identifiable name.
- Description—Opt to include a policy description.
- Enabled—If enabled, the policy becomes active when saved.
- Schedule Policy (UTC)—Schedule how often the policy runs: Daily,
Weekly, or Monthly. All times are in UTC. Adjust the time according
to your time zone.
- When selecting Day, you are prompted for the Hour
- When selecting Week, you are prompted for the day of the week (Sunday-Saturday) and the Hour.
- When selecting Month, you are prompted for the day of the month and the Hour.
-
In the Query Details section, populate these fields as part of the
policy.
- Archive SObject:
LLC_LoanDocument - Take Action When:
All conditions are met - Field:
LLC_BI__Loan__c - Operator:
equals - Value:
Golf Augusta Pro Shops - Real Estate Only - Logic:
AND
- Archive SObject:
-
After the
AND, populate these fields in the second row.- Field:
LLC_BI__attachmentId__c - Operator:
is not empty
- Field:
-
Add this codeblock to SOQL Query.
SELECT Id FROM LLC_BI_LLCLoanDocument_c WHERE LLC_BI_Loan_r.Name + 'Golf Augusta Pro Shops - Real Estate Only' AND LLC_BI_AttachmentId_c!="LIMIT 10 - Select Include ContentDocuments.
- Click Accept.
-
To select the fields that are available in your widget view, click
Preview Table.
You can select up to 15 fields.
- Save your work.
View the Archived Data
To customize the page:
-
Add the Lightning Web Component to the Loan Object Page.
In this example, we create a custom tab named Archived Documents and placed it next to Documents.
- View the Archived Documents under the loan named Golf Augusta Pro Shops - Real Estate Only.
-
To view the actual ContentDocument, click
CurrentAttachmentId.
This action takes you to the ContentDocument. To see a preview version, click the right-hand side of the ContentDocument. If the Placeholder has multiple versions, the latest version of the ContentDocument is displayed.
-
To view all versions of a Placeholder with ContentDocument, click
Viewunder the little arrow on the right of the Placeholder.This action takes you to the Loan Placeholder (LLC_LoanDocument) Detail tab.- From the Detail tab, go to the Related tab.
- Under Related, you can see the Document Manager underlying Infrastructure. The Document Stores (1) Related Lists has all versions of the ContentDocument.
-
Click the Document Store Name link, or click
Viewon the right to get to the Document Store Detail Page. -
From the Detail tab, go to the Related tab.
The Related list displays all three versions of the ContentDocuments and ContentDocument Links and the link to the Document Store Indices.
- To see a preview version, click the right-hand side of any of the ContentDocuments.
Same Root and Child Filter
Automatically exclude root records from a dataset when they have children of the same object type. This filter addresses a specific limitation in Salesforce Object Query Language (SOQL) and enables more advanced filtering of hierarchical data in the Archive app.
Same Root and Child Filter can be found in Archive Settings under the Archive tab. This feature lets you effectively isolate standalone or "leaf" records in a hierarchy for processing. For example, if a Case record is the root record of another Case, this filter excludes the root record, leaving only the child records.
Although SOQL makes it easy to filter records based on a relationships to different objects, such as finding Accounts with no Contacts, SOQL doesn't support direct queries to filter records based on relationships to the same object. For example, you can't use SOQL to find Cases that aren't root records of other Cases.
Same Root and Child Filter bridges this SOQL gap. This feature programmatically analyzes your records to provide this capability, enabling a more advanced level of filtering on hierarchical data.
Enable Archiving of Objects with Missing Relationship Names
When archiving related records, the Archive app typically relies on defined
relationship names to navigate root-child relationships. These relationship names are used
in subqueries to identify and retrieve child records associated with a root record. However,
some objects don't expose relationship names in the metadata, which can limit or block the
archiving process for those object types. To archive these objects, use the Enable Archiving
of Objects with Missing Relationship Names setting and then filter
ContentLocation by any external content references.
For example, in this query FeedItems is the relationship name that
connects the Account root object to its related
FeedItem child record.
SELECT Id, (SELECT Id FROM FeedItems) FROM Account
WHERE Id IN ('account_id_1', 'account_id_2')Some objects, such as FeedItem, don't expose relationship names in
the metadata. Archive can't use subqueries to retrieve related records, which can
hinder the archiving process for those object types.
When Enable Archiving of Objects with Missing Relationship Names is enabled, Archive
uses foreign key fields, such as ParentId, to retrieve related
records directly, without depending on relationship names. If the setting isn't
enabled, the previous query fails because FeedItem lacks a subquery
relationship name to Account.
Filter By External Content References
You can filter records based on where their content is stored.
For example, a FeedItem object includes a
ContentLocation field that identifies whether content is stored
externally (E) or within Salesforce (S).
To avoid archiving records with externally stored content, you can add a filter to your query.
SELECT Id FROM FeedItem WHERE ParentId IN (list of Account Ids) AND ContentLocation != 'E'By applying this filter, only FeedItem records with content stored in Salesforce
are archived.

