---
schema_version: "1"
id: d5c006162db424036fdae458701add2377576dbe271c218645226fde68862f80
title: Delete Health Verification Attachments and Health Card Records Automatically with an Apex Job
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/service/264-0-0/vaccine_packages_delete_hv_attachments.md
canonical_url: https://help.salesforce.com/s/articleView?id=service.vaccine_packages_delete_hv_attachments.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: fa2af797e06d49c9c612810db22b1ed3cb369f02795d81e0f0c61ca3c935954c
description: Help keep customers’ personal health information private and safe by regularly deleting verification files and Health Card records. Simply schedule the job, and it runs at the specified time.
products:
  - Salesforce Platform
release: "264"
---
# Delete Health Verification Attachments and Health Card Records Automatically with an Apex Job

Help keep customers’ personal health information private and safe by regularly deleting verification files and Health Card records. Simply schedule the job, and it runs at the specified time.

The job uses the schedulable class `SafetyCloudPurger` to automatically delete the verification file attached to a Health Verification record or to delete Health Card records and associated data, such as dose information.

Each batch performs these actions on Health Verification records that have a Health Verification Status of Verified.

- Fetch Health Verification records with `EventDate__c <= YESTERDAY AND AttachmentPurgedTimestamp__c = null`.
- Delete the Health Card record and associated data.
- If the record has `attachment`:
    1. Delete the attachment record.
    2. Set `AttachmentPurgedTimestamp__c` to the current time.

Safety Cloud relies on a Custom Setting named Safety Cloud Purge Setting to determine how many days after an event to wait before purging file attachments and Health Card-related data from the system.

By default, Safety Cloud purges Health Card and Health Verification data 1 day after the event. To modify the Safety Cloud Purge setting complete these steps.

1. From Setup, in the Quick Find box, enter Custom Settings, and then select Custom Settings.
2. Select the Safety Cloud Purge Setting.
3. Click **Manage**.
    
    If there’s no Default Organization Level Value, Safety Cloud purges Health Verification and Health Card-related data 1 day after the event.
4. To set a default value for purging data, click **New**, and set a value for Days After Event.
5. Save your changes.
    
    After setting the Default Organization Level Value, you can go back at any time and edit the value specified in Days After Event.

To schedule the job, complete these steps.

1. From Setup, in the Quick Find box, enter Apex Classes, and then select **Apex Classes**.
2. Click **Schedule Apex**.
3. Enter the job name. We recommend Health Verification Data Purge.
4. In the search bar, enter SafetyCloudPurger, and select it.
5. Specify the start and end dates for the Apex scheduled class. If you specify a single day, the job runs only one time.
6. Specify a preferred start time. The exact start time depends on service availability.
7. Save your changes.

When it completes, you can see the job’s information on the [Apex Jobs](https://help.salesforce.com/articleView?id=code_apex_job.htm&language=en_US) page, such as whether it passed or failed, how long it took to process, and the number of records processed.