Skip to content

Import records for multiple objects

You can import more than one object type — Contacts and Companies, for example — in a single upload. The key is the template’s datamap sheet, which until now only had one row.

The template downloaded from More actions → Download template ships three sheets: README (technical instructions for importing via the API), datamap (the map of which sheet maps to which object), and a sheet named after the object (Contact, Company…) with the real columns.

The datamap sheet looks like this:

sheetNameobjectTypefromtoskip
ContactContactfalse

Each row tells the importer: “process the sheetName sheet as records of the objectType object.” By default there’s only one row — the one for the module you downloaded the template from.

To import Contacts and Companies together, for example:

  1. Download the Contacts template (or open one that already has data).
  2. Also download the Companies template and copy its entire Company sheet (with its columns) into the same file.
  3. In the datamap sheet, add a second row: sheetName = Company, objectType = Company.
  4. Fill in the data on each sheet as usual and save the file.
  5. Upload the file once from More actions → Import, in either of the two modules.

The datamap sheet ends up looking like this:

sheetNameobjectTypefromtoskip
ContactContactfalse
CompanyCompanyfalse

Prolibu processes each declared sheet as an independent import, but within the same upload: the Import data panel shows a combined counter (2 Total, 2 Imported in this example) with its own progress bar per object.

Import data panel showing 2 Total and 2 Imported, with both the Contacts and Companies rows marked Completed

If you need to load several record types without linking them to each other — the most common case — this already solves it: two objects, one file, one upload.

Linking the records: the company has to exist first

Section titled “Linking the records: the company has to exist first”

The company reference column only resolves against a company that already exists at the moment that contact row is processed — not against a row further down the same file. That gives two valid paths, and in both the field that links is the same: company must carry the company’s companyCode, not its refId or its name.

In the same upload, with the right order in datamap

Section titled “In the same upload, with the right order in datamap”

If Contacts and Companies go in the same file (see above), the importer processes sheets in the order they appear in datamap. Put the Company row before the Contact row:

sheetNameobjectTypefromtoskip
CompanyCompanyfalse
ContactContactfalse

With that order, by the time it’s the Contact sheet’s turn the company already exists and the company column finds it: open the contact’s record and the Company field is genuinely linked, not just the plain name the table shows. Reverse the order (Contact before Company) and the contact upload fails row by row with “Document not found by primary key ‘‹code›’ in ‘company’”, because at that point in the process the company doesn’t exist yet.

If you’d rather not depend on sheet order — or the company already existed — upload companies first and contacts next:

  1. Companies first. Upload the file with the Company sheet and give each one its own companyCode.
  2. Contacts next. In the Contact sheet, fill the company column with that same companyCode.

companyCode also works as a unique key, so re-uploading the same Company sheet updates the company instead of duplicating it.

Frequently asked questions

Was this article helpful?