Form Version Import allows for a way to exclusively import JSON into a target Org, without the automatic creation of the corresponding Smart Form components such as Elements, Sections and Picklists that are present in the source Org. The JSON for a Form Version is static and essentially a snapshot of the definitions of a Smart Form that the Axsy app can retrieve and display without the corresponding Elements, Sections and Picklists being present in the target Org.
Please ensure you have exported the correct Form Version or Draft of your Smart Form by covering this article: Exporting Smart Forms
What Happens to the JSON When You Publish a Smart Form?
When you publish a Smart Form, a versionId tag gets added to the JSON when it is created. The Form then becomes a Form Version with a tag identifier that is picked up during import in Workbench. This is what differentiates Drafts and Form Versions, as when Draft Forms have their JSON exported, no versionId tag exists.
Please see this article for more information on how to publish Smart Forms in the Designer: Smart Forms - Versioning
Steps to Import a Form
Login to Workbench with the credentials for your target Org. Navigate to Utilities > Rest Explorer and Select the POST HTTP request.
- In the POST request field insert /services/apexrest/axsy_forms/form?upsert or /services/apexrest/axsy_forms/form .
- In the request body, paste the JSON from your exported Smart Form.
- Select Execute.
Form Version Import Methods
Form Version numbers are not imported across Orgs. For example, if you have imported three versions of a Form into the target Org but then create three more in the source Org, the sixth version in the source Org will become the fourth when imported into the target Org.
- Use POST request /services/apexrest/axsy_forms/form?upsert .
- No Smart Form components (Elements, Picklists and Sections) are created in the target Org.
- This method will import a version of a published Form into an Org with a blank Designer (when no Draft version of the Form is already present in the target Org). If Drafts of the Form are already present in the target Org, the Designer will display the latest Draft in the Designer for the subsequent Form Versions that are imported into the Org (unrelated to the JSON for the Form Version).
- Users will not be able to edit Form Versions in the target Org as there is no corresponding UI in the Designer and so they remain immutable.
- Use POST request /services/apexrest/axsy_forms/form .
- Importing a Form this way into an Org where it doesn't already exist (Draft or published Form Version) means that an error will occur as there is nothing to update. The error will prompt the user to Upsert the Form.
- If a version of the Form does exist in the target Org, this method of Import behaves identically to Importing a Form Version with Upsert.
Form Draft Import Methods
When no versionId tag is present in the JSON during an import, it is treated as a Draft Import. While these methods of Draft Import below are still supported, they are considered deprecated.
- Use POST request /services/apexrest/axsy_forms/form .
- Importing a Draft Form without Upsert will always create a new Form. If a Draft of the Form already exists in the target Org, this import method will create a new Draft and duplicate any Smart Form components such as Elements, Sections and Picklists that are already present in the target Org.
- Use POST request /services/apexrest/axsy_forms/form?upsert .
- If a Draft of the Form already exists in the target Org, this import method will look for the existing Draft and update changes that have been made to the Form in the source Org, to the Form in the target Org. No new Form is created and nothing is removed from the target Org that has since been removed in the source Org. In other words, Importing a Draft with Upsert will never delete a Form component or record.
- If no other Draft of the Form is already present in the target Org, a new Draft Form will be created.
- Underlying Smart Form components are always created/updated in the Designer of the target Org – no duplicates will be created of existing components.
- If you try and Upsert a Draft Form in a target Org where there are multiple Smart Form components that already share the same Name, an error will occur: More than one record found... This is because it is not clear which Smart Form component should be updated.
Make a Form Version a Draft for Import by Editing its JSON
You can make a Form Version a Draft by editing its exported JSON before an import. To do this, you need to remove the versionId tag in the JSON and save the file again. It will then be treated as a Draft Form during the import.
Error Checking Using &nobatch
The import methods described in this article are performed asynchronously – which allows large JSON files to be imported via Salesforce Workbench. A disadvantage of asynchronous commands is that import validation error messages are not reported. If your JSON file size is smaller than approximately 500KB you can use the additional import parameter: &nobatch on any of the POST requests listed in this article to perform imports synchronously – which will allow any import validation errors detected by Salesforce Workbench to be reported. An example complete command is shown below:
/services/apexrest/axsy_forms/form?upsert&nobatch