action.skip

Invoice Migration

A business may require to move invoices that were created with JustOn from one Salesforce org to another Salesforce org. This migration procedure does not require preparing data sources or fixing imported records, as with importing invoices from third-party systems (see Invoice Import and Fix). Nevertheless, it involves some complex operations.

Info

JustOn recommends to have invoices migrated by experienced administrators. In case of doubt, contact JustOn Support.

Hence, this article does not provide detailed descriptions for all involved tasks. Instead, it gives the administrator a guideline of the major steps to take:

Prerequisites

The following instructions assume that

  • The accounts have set a custom field that is marked as External ID (like ExtId for the purpose of this article),
  • The accounts are already migrated to the target org.

Preparing Export

Before actually exporting the original data from the source org, the following preparation tasks are required:

  1. Create a MigrationID field on the Invoice, Invoice Line Item and Balance objects in the source org.

    API Name Data Type Value
    MigrationID__c Formula (Text) CASESAFEID(Id)
  2. Create a MigrationParentID field on the Invoice and Invoice Line Item objects in the source org.

    Object API Name Data Type Value
    Invoice MigrationParentID__c Formula (Text) CASESAFEID(ONB2__Account__r.ExtId)
    Make sure to use the External ID field set for accounts.
    Invoice Line Item MigrationParentID__c Formula (Text) CASESAFEID(ONB2__Invoice__r.Id)

Once completed, you can proceed to export all relevant fields of all involved objects.

Note

Make sure to export only lookup fields that relate to available records in the target org, including accounts, invoices, invoice line items, balances and templates.

Preparing Import

Before importing the exported data to the target org, the following preparation tasks are required:

  1. Create a MigrationID field on the Invoice, Invoice Line Item and Balance objects in the target org.

    API Name Data Type Notes
    MigrationID__c Text Requires the External ID attribute.
  2. Deactivate the Apex triggers for balances, invoices and invoice line items.

    Create Trigger Settings for all existing Apex triggers that start with Balance, Invoice and InvoiceLineItem.

  3. Clean up the exported CSV files.

    1. In particular, make sure that the format of date fields corresponds to this pattern:

      yyyy-mm-dd + T01:00:00.000Z
      
    2. In the invoices CSV file, replace the template ID of the source org with the template ID of the target org.

Executing Import

In the target org, you import the invoice data using the Data Loader. Proceed as follows:

  1. For every object, create a mapping to associate the columns of the CSV file with the corresponding Salesforce fields.

    When doing so, make sure to remove formula fields and roll-up fields from the mapping.

  2. Upsert the invoices.

    1. Use the ExtId field for matching.
    2. Associate the invoices with accounts using ONB2__Account__r.ExtId__c.

      Ignore other relations initially.

    3. Update the missing relations to related invoices (in case of cancellations and credits).

  3. Upsert the invoice line items.

    1. Use the MigrationID field for matching.
    2. Associate the invoice line items with invoices using ONB2__Invoice__r.MigrationID__c.

      Ignore other relations initially.

    3. Update the missing relations to related invoice line items.

  4. Upsert the balances.

    1. Use the ExtId and MigrationID fields for matching.
    2. Associate the balances with accounts using ONB2__Account__r.ExtId__c and invoices using ONB2__Invoice__r.MigrationID__c.

      Ignore other relations initially.

    3. Update the missing relations to related balances.

Additional Tasks

After completing the data import, the following additional tasks are required:

  1. In the target org, re-enable the Apex triggers for balances, invoices and invoice line items.

    To do so, delete the trigger settings records created before.

  2. Deselect, if set initially, the Unique attribute from the MigrationID field definitions on the Account, Invoice, Invoice Line Item and Balance objects.

Related information:

Invoice Import and Fix
How to import invoices using the Data Loader?
Insert, Update, or Delete Data Using Data Loader in the Salesforce Developer Documentation