Setting Up Invoice Migration
← Configuring Invoice Management
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:
-
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)
-
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:
-
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. -
Deactivate the Apex triggers for balances, invoices and invoice line items.
Create Trigger Settings for all existing Apex triggers that start with
Balance
,Invoice
andInvoiceLineItem
. -
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
-
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:
-
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.
-
Upsert the invoices.
- Use the
ExtId
field for matching. -
Associate the invoices with accounts using
ONB2__Account__r.ExtId__c
.Ignore other relations initially.
-
Update the missing relations to related invoices (in case of cancellations and credits).
- Use the
-
Upsert the invoice line items.
- Use the
MigrationID
field for matching. -
Associate the invoice line items with invoices using
ONB2__Invoice__r.MigrationID__c
.Ignore other relations initially.
-
Update the missing relations to related invoice line items.
- Use the
-
Upsert the balances.
- Use the
ExtId
andMigrationID
fields for matching. -
Associate the balances with accounts using
ONB2__Account__r.ExtId__c
and invoices usingONB2__Invoice__r.MigrationID__c
.Ignore other relations initially.
-
Update the missing relations to related balances.
- Use the
Additional Tasks
After completing the data import, the following additional tasks are required:
-
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 (step 2 under Preparing Import).
-
Deselect, if set initially, the
Unique
attribute from theMigrationID
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