{"id":51459583,"url":"https://github.com/trusthumankind/sfdc-dml-history","last_synced_at":"2026-07-06T04:01:48.290Z","repository":{"id":77997712,"uuid":"102807824","full_name":"trusthumankind/sfdc-dml-history","owner":"trusthumankind","description":"Track DML operations, including merge operations for accounts, contacts and leads","archived":false,"fork":false,"pushed_at":"2020-04-06T03:35:30.000Z","size":50,"stargazers_count":2,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-16T18:12:12.415Z","etag":null,"topics":["dml","salesforce"],"latest_commit_sha":null,"homepage":"","language":"Apex","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trusthumankind.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2017-09-08T02:29:37.000Z","updated_at":"2020-04-06T03:35:33.000Z","dependencies_parsed_at":"2023-03-12T03:12:27.650Z","dependency_job_id":null,"html_url":"https://github.com/trusthumankind/sfdc-dml-history","commit_stats":null,"previous_names":["trusthumankind/sfdc-dml-history"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/trusthumankind/sfdc-dml-history","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trusthumankind%2Fsfdc-dml-history","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trusthumankind%2Fsfdc-dml-history/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trusthumankind%2Fsfdc-dml-history/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trusthumankind%2Fsfdc-dml-history/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trusthumankind","download_url":"https://codeload.github.com/trusthumankind/sfdc-dml-history/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trusthumankind%2Fsfdc-dml-history/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35177220,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-06T02:00:07.184Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dml","salesforce"],"created_at":"2026-07-06T04:01:45.182Z","updated_at":"2026-07-06T04:01:48.221Z","avatar_url":"https://github.com/trusthumankind.png","language":"Apex","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Salesforce DML History\n\nCapture merge history for accounts, contacts and leads, enabling easy lookups\nacross multiple merge operations while also providing a means\nto manually undo accidental merges.\n\nAlso capture simple DML history, notably for `delete` operations.\n\n## Installation\n\nUse the [Salesforce DX CLI][1] to deploy the code to your Salesforce org.\n\n```bash\nsfdx force:source:convert -r force-app -d src\nsfdx force:mdapi:deploy -d src -w 5\n```\n\n[1]: https://developer.salesforce.com/tools/sfdxcli\n\n## Merge History Quick Start\n\nTo enable merge history tracking for an object, open\nthe **Merge History Trigger** custom setting and create a new record for\nevery object where tracking is enabled.\n\nField Label | Description\n----------- | -----------\nName | The API name of the object. Currently only \"Account\", \"Contact\" and \"Lead\" are supported.\nActive | Whether merge history tracking is active for this object\n\nMerge History captures history using **Merge Result** records. Every result\nmay have sets of fields that follow the same convention as the included\nsample set.\n\nField Label | Field Name | Description\n----------- | ---------- | -----------\nMerged Record ID | `MergedRecordId__c` | The Salesforce ID of the merged record\nMaster Record ID | `MasterRecordId__c` | The Salesforce ID of the master record in the merge operation performed\nEffective Master Record ID | `EffectiveMasterRecordId__c` | The Salesforce ID of the currently surviving master record, if the master record in this merge operation was later merged into another record. This field will always contain the ID of a surviving master record, unless that record was deleted by another non-merge process.\n\nMerge History allows you to add custom fields such as external ID fields\nto be included in merge results for easy crosswalks or lookups\nin system integration or data migration use cases.\n\nLet's say your Account object has a custom external ID field\nnamed `NetsuiteCustomerId__c`, and you want to track this field value\nin merge results.\n\n1. On the Merge Result object, create a Merged Record field named `MergedRecordNetsuiteId__c`. Note that the field name _must_ start with `MergedRecord`.\n2. On the Merge Result object, create a Master Record field named `MasterRecordNetsuiteId__c`. Note that the field name _must_ start with `MasterRecord`, and the rest of the name must match that of the Merged Record field.\n3. On the Merge Result object, create an Effective Master Record field named `EffectiveMasterRecordNetsuiteId__c`. Note that the field name _must_ start with `EffectiveMasterRecord`, and the rest of the name must match that of the Merged Record field.\n4. Add the record below to the Merge Result Field Mapping custom metadata type\n\nField | Value\n----- | -----\nLabel | Account: NetSuite Customer ID\nMerge Result Field Mapping Name | AccountNetsuiteCustomerId\nObject | Account\nField Name | NetsuiteCustomerId__c\nResult Field Ending | NetsuiteId__c\n\nRemember to grant at least **Read** permission on all fields\non the Merge Result object to the System Administrator profile!\n\n## DML History Quick Start\n\nDML History currently only supports tracking delete operations.\n\nTo track delete operations any object that supports Apex triggers,\ncreate a standalone  Apex trigger like the following.\n\n```java\ntrigger AccountDeleteTrigger on Account (after delete) {\n    DmlHistoryService.getInstance().trackDelete(Trigger.old);\n}\n```\n\nTo provide code coverage for this simple trigger, create the following class.\n\n```java\n@isTest\nprivate class AccountDeleteTriggerTest {\n\n    @isTest\n    private static void deleteRecord() {\n\n        // Given\n        insert new Account(\n            Name = 'Acme, Inc. (TEST)'\n        );\n        \n        // When\n        Test.startTest();\n\n        delete [SELECT Id FROM Account WHERE Name = 'Acme, Inc. (TEST)'];\n\n        // Then\n        Test.stopTest();\n\n        System.assertNotEquals(\n            null,\n            [SELECT Id FROM DmlOperation__c WHERE Type__c = 'delete'].Id,\n            'ID should prove Delete Operation record exists'\n        );\n    }\n}\n```\n\nTo track delete operations with the additional granularity of the record IDs\nfor every single deleted record logged separately, use the overloaded\n`trackDelete` method as follows.\n\n```java\ntrigger OpportunityLineItemDeleteTrigger on OpportunityLineItem (after delete) {\n    DmlHistoryService.getInstance().trackDelete(Trigger.old, true);\n}\n```\n\n## Development\n\n```bash\nsfdx force:org:create -f config/project-scratch-def.json -s\nsfdx force:source:push\nsfdx force:user:permset:assign -n DmlHistory\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrusthumankind%2Fsfdc-dml-history","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrusthumankind%2Fsfdc-dml-history","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrusthumankind%2Fsfdc-dml-history/lists"}