Migrate Platform Keys (pre-1.81)
How to migrate Platform Keys created in pre-1.81 version to use the new structure.
This article is only relevant to customers that use Extension: Fundraising & Donations and have/had a pre-1.81 version in operation.
Occasionally, when a contact is deleted from Salesforce, an error can occur when the unique identifier for the contact reappears in subsequent MoveData notifications. This is due to the Platform Key record still existing (see Duplicate Detection) but no longer having any contact to point to. This would manifest as an error Platform Key linked to another Record which has been resolved since Extension: Fundraising & Donations reached version 1.81 (Aug 2022).
If you have been using a pre-1.81 version, you will need to migrate your platform keys to a new structure to address this issue. If you update to 1.81+ and do not perform the migration, you are at risk of a large number of duplicate records being created over time. As such this is a mandatory upgrade for all customers on a pre-1.81 version of Extension: Fundraising & Donations.

Performing the Migration

The migration is straight-forward to execute with System Administrator privileges. To complete, please follow the below steps:

1. Install the most recent version of the NPSP extensions

  • Navigate to the MoveData application in Salesforce
  • Select the "Settings" tab
  • Navigate to the "Extensions" tab
  • Find the "Extension: Fundraising & Donations" entry and click "Update" to get to the most recent NPSP extensions installed.
  • Follow the install instructions to complete the install

2. Execute the migration script

  • Open the "Developer Console"
    • Click the
      icon on the top right on the screen and select "Developer Console" from the menu.
  • Select "Debug -> Open Execute Anonymous Window"
Execute Anonymous Window
  • Copy and paste the below script into the "Enter Apex Code" window.
List<md_npsp_pack__Contact_Platform_Key__c> lstContact = new List<md_npsp_pack__Contact_Platform_Key__c>();
List<md_npsp_pack__Account_Platform_Key__c> lstAccount = new List<md_npsp_pack__Account_Platform_Key__c>();
List<md_npsp_pack__Platform_Key__c> lst = [SELECT Id, Name, md_npsp_pack__Platform__c, md_npsp_pack__Platform_Key__c, md_npsp_pack__Contact__c, md_npsp_pack__Account__c FROM md_npsp_pack__Platform_Key__c LIMIT 2000];
System.Debug('List Size: ' + lst.size());
for (md_npsp_pack__Platform_Key__c item : lst) {
if (item.md_npsp_pack__Contact__c != null) {
md_npsp_pack__Contact_Platform_Key__c record = new md_npsp_pack__Contact_Platform_Key__c();
record.md_npsp_pack__Platform__c = item.md_npsp_pack__Platform__c;
record.md_npsp_pack__Platform_Key__c = item.md_npsp_pack__Platform_Key__c;
record.md_npsp_pack__Contact__c = item.md_npsp_pack__Contact__c;
if (item.md_npsp_pack__Account__c != null) {
md_npsp_pack__Account_Platform_Key__c record = new md_npsp_pack__Account_Platform_Key__c();
record.md_npsp_pack__Platform__c = item.md_npsp_pack__Platform__c;
record.md_npsp_pack__Platform_Key__c = item.md_npsp_pack__Platform_Key__c;
record.md_npsp_pack__Account__c = item.md_npsp_pack__Account__c;
System.Debug('Contact List Size: ' + lstContact.size());
System.Debug('Account List Size: ' + lstAccount.size());
if (lstContact.size() > 0) insert lstContact;
if (lstAccount.size() > 0) insert lstAccount;
delete lst;
  • Ensure the "Open Log" checkbox is checked.
    • This will open a log to enable us to see if the job is complete.
  • Click "Execute" to run the script.

3. Confirm the script has completed

  • The log should open automatically.
  • Click the "Debug Only" toggle.
  • The output should identify how many records have been migrated.
  • If the List Size in the debug output is greater than 0, then rerun the script.
    • This will ensure that all records have been migrated.
  • Once all records are migrated, the Debug Log (with the "Debug Only" toggle checked) will look like this:

System.DmlException in Migration

In rare cases you may get the following error when performing your migration:
System.DmlException: Insert failed. First exception on row 440; first error: DUPLICATE_VALUE, duplicate value found: md_npsp_pack__Platform_Key__c duplicates value on record with id: a1t980000003zBr
In this scenario, perform the following to remove the offending record:
  • Open record using ID (ie. use a1t980000003zBr and https://your-domain.lightning.force.com/ to construct https://your-domain.lightning.force.com/a1t980000003zBr)
  • Copy the platform key value (for example, funraisin:2242)
  • Query the existing platform key record
    • Click the
      icon on the top right on the screen and select "Developer Console" from the menu
    • Select Query Editor and run the following query (substituting for your platform key value in the following example): SELECT Id, Name, md_npsp_pack__Platform__c, md_npsp_pack__Platform_Key__c, md_npsp_pack__Contact__c, md_npsp_pack__Account__c FROM md_npsp_pack__Platform_Key__c WHERE md_npsp_pack__Platform_Key__c = 'funraisin:2242'
  • Copy the resulting ID to open the record
  • Delete the record
  • Rerun script to complete migration
Copy link
Performing the Migration
System.DmlException in Migration