Archiving Policies

    We recommend reviewing the questions below before starting to create Archiving Policies.

    • Which objects and related objects do you want to archive and why? 
    • What is the scheduled frequency the Archive should run (weekly / daily / monthly)?
      • What day of the week or month and time should the archive policy run?
    • Who has the ability to set up archiving policies (Admins only)?
      • Permission Sets can be assigned to appropriate system admins
      • OwnBackup_CDE_Policy permission set will allow the user to create, delete and edit the policy
    • Who needs to see the archived data? (Admins only / End users / Auditors / etc.) 
    • Who has access to the unarchive records? ( Admins only / End users / Auditors / etc.)
      • Permission Sets can be assigned to appropriate users
      • OwnBackup_Unarchive permission set will allow the user to unarchive records

    Example of use cases & Queries 

    NOTE:  For testing purposes, we recommend starting out with a low limit to initially test the policy

    1. Archiving Tasks 

    • Object: Task 
    • Use Case: Archiving Tasks that are associated with a specific record type of contact (ie RecordTypeID = ‘abc’)  and last modified more than 2 years ago
    • Limit = 5, will archive 5 tasks in each run and its related objects 
    • Preview:  Id, Activity Date, Category (custom field) Description, Owner ID, Subject, Status
    Select Id FROM Task WHERE Whold IN (SELECT Id FROM Contact WHERE RecordTypeid = 'abc') AND ActivityDate<LAST_N_DAYS: 730 LIMIT 5

     

    2. Archiving Cases 

    • Object: Case 
    • Use Cases: Archive cases that meet the following criteria:
      • Status is closed
      • Created more than 30 days ago 
    • Limit = 5000,  will archive 5000 cases in each run and its related objects 
    • Preview: Id, Case Number, Type,  Sub Category (custom field), Issue (custom field)

     

    Select Id From Case WHERE Status = 'Closed' AND CreatedDate < LAST_N_DAYS: 30 LIMIT 5000

     

    3. Archiving Cases From a Specific Account  

    • Object: Case 
    • Use Cases: Archive cases that meet the following criteria:
      • Status is closed
      • Created more than 30 days ago
      • And belongs to an account with Id=1234  
    • Limit = 5000,  will archive 5000 cases in each run and its related objects 
    • Preview: Id, Case Number, Type,  Sub Category (custom field), Issue (custom field)
    Select id FROM Case Where accountId IN (SELECT id from Account where id ='1234XXXXXXXXXXXXXXX') AND Status = 'Closed' AND CreatedDate < Last_N_Days:30 LIMIT 5000

      4. Archiving Attachments  

      • Object: Attachment  
      • Use Cases: Archiving attachments that their:
        • The parent is an Opportunity in a stage that is either ‘Signed Off’ Or 'Asbestos Completed' 
        • The Opportunity Close Date is more than 6 months in the past
      • Limit = 2500,  will archive 2500 attachments in each run and its related objects 
      • Preview: Id, Parent ID, Created Date
      Select IdFROM Attachment Where ParentId IN (SELECT Id FROM Opportunity WHERE (StageName='Signed Off' OR StageName='Asbestos Completed') AND CloseDate < N_MONTHS_AGO:6) LIMIT 2500

       

      5. Archiving Contacts  

      • Object: Contact  
      • Use Cases: Archiving contacts that their:
        • Archiver__c field is set to True 
      • Limit = 1000,  will archive 2500 contacts in each run and its related objects 
      • Preview: Id, Parent ID, Created Date
      Select Id FROM Contact Where  Archiver__c = true Limit 1000
      « Previous ArticleNext Article »