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:

Preparing Export

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

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

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

    Object API Name Data Type Value
    Invoice SourceParentID__c Formula (Text) CASESAFEID(ONB2__Account__r.Id)
    Invoice Line Item SourceParentID__c Formula (Text) CASESAFEID(ONB2__Invoice__r.Id)

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

Preparing Import

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

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

    API Name Data Type Notes
    SourceID__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.

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

    yyyy-mm-dd + T01:00:00.000Z
    

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 SourceID field for matching.
    2. Associate the invoices with accounts using ONB2__Account__r.SourceID__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 SourceID field for matching.
    2. Associate the invoice line items with invoices using ONB2__Invoice__r.SourceID__c.

      Ignore other relations initially.

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

  4. Upsert the balances.

    1. Use the SourceID field for matching.
    2. Associate the balances with accounts using ONB2__Account__r.SourceID__c and invoices using ONB2__Invoice__r.SourceID__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 SourceID 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