A form is not stored in one field. It is a small object record plus one or more Files attached to that record. To move a form to another org you move the records and the Files together, in the right order, and repoint the lookups.
| Piece | Where it lives | Notes |
|---|---|---|
| Form identity | Form__c record |
Availability window, context object, style lookup |
| Form definition | File Template.3bt on the Form__c |
Stored as a ContentDocument with one ContentVersion per saved version |
| Theme | File theme_config.json on the Form__c |
Only the latest version is used |
| Custom CSS | Form_Style__c record |
Custom_Code__c long text, referenced by Form__c.Form_Style__c |
Because the definition and theme are Salesforce Files, this is a ContentVersion migration wrapped around a small record migration. Get the Files wrong and the form record exists but renders nothing.
Forms_General_Settings__c, Security_Settings__c) are configured in the target org. These are org level and are not part of a form migration. See Settings reference.Lookups must exist before the records that point at them, and a File's ContentDocument must exist before you can link it. Load in this order:
Form_Style__c recordsForm__c records, with Form_Style__c repointed to the new style IdsContentVersion rows for each form's Template.3bt and theme_config.jsonContentDocumentLink rows joining each new ContentDocument to its new Form__cEvery insert changes record Ids. The new org will not reuse the source Ids, so you must be able to translate a source Id to its target Id at every step.
The simplest way is to keep a source Id column in every extract and rely on the Data Loader success file, which writes the new Id onto each input row in the same order. After each insert you have a two column map: source Id, target Id.
If you migrate the same forms repeatedly (for example dev to test to prod), add an unprotected External Id text field to Form__c and Form_Style__c, stamp it with the source Id, and use Upsert instead of Insert. That makes every run idempotent and removes the manual join.
Export Form_Style__c (Id, Name, Custom_Code__c). Insert into the target. Save the source Id to new Id map.
Export Form__c with at least:
Id, Name, Object_Name__c, Form_Style__c, Date_Available_Start__c, Date_Available_End__c
Before insert, replace Form_Style__c with the new style Id from your Step 2 map. Insert, and save the Form__c source to new map. You now have empty form shells with no definition or theme attached.
This is the part that most migrations get wrong. A Salesforce File is three objects: a ContentDocument, one ContentVersion per saved version, and a ContentDocumentLink that attaches the document to a record.
Query the ContentVersions for the forms you are moving. Join through ContentDocumentLink to find the documents linked to each Form__c:
SELECT Id, Title, PathOnClient, VersionData, ContentDocumentId,
VersionNumber, ReasonForChange, CreatedDate
FROM ContentVersion
WHERE ContentDocumentId IN (
SELECT ContentDocumentId FROM ContentDocumentLink
WHERE LinkedEntityId IN ('<sourceFormId>', ...)
)
ORDER BY ContentDocumentId, CreatedDate ASC
VersionData is the file body. Data Loader can export it to files and re-import it by path. Keep the ordering by ContentDocumentId then CreatedDate so versions load oldest first.
Template.3bt version per document and the single theme_config.json.For each source document, insert its versions in order:
ContentDocumentId. Salesforce creates a fresh ContentDocument and returns the new ContentVersion Id.ContentDocumentId set to the new document Id from that first insert. This rebuilds the version chain under one document.Map the fields:
| Target field | Value |
|---|---|
Title |
Template.3bt or theme_config.json |
PathOnClient |
same as Title, sets the file extension |
VersionData |
the exported file body |
ReasonForChange |
carry the source value to preserve the save reason |
ContentDocumentId |
blank for the first version, new document Id for the rest |
After each insert, record the map of source ContentVersion Id to new ContentVersion Id. Keep this map. Response migration depends on it entirely.
Inserting the first ContentVersion created a ContentDocument but did not attach it to your Form__c. Insert one ContentDocumentLink per document:
| Field | Value |
|---|---|
ContentDocumentId |
new document Id |
LinkedEntityId |
new Form__c Id from Step 3 |
ShareType |
V |
Visibility |
AllUsers |
Form__c and confirm both Template.3bt and theme_config.json show under Files.| Symptom | Cause | Fix |
|---|---|---|
| Form record exists but renders blank | Template.3bt not attached |
Missing or wrong ContentDocumentLink in Step 4 |
| Form renders unstyled | theme_config.json missing, or Form_Style__c lookup not repointed |
Re-link the theme File, fix the style Id in Step 3 |
| Only the latest version shows in history | Versions loaded as separate documents | Reload with ContentDocumentId chaining so all versions share one document |
| Style applies to the wrong form | Form_Style__c still holds source Ids |
Repoint using the Step 2 map before inserting Form__c |