In this guide, we’ll walk through how to import and export OmniScripts, DataRaptors, and Integration Procedures between Salesforce orgs using VS Code and the Salesforce CLI. This approach significantly simplifies moving your OmniStudio configurations, whether you’re migrating from sandbox to production or between different development environments.
This process eliminates the need for manually recreating your OmniScripts, DataRaptors, and Integration Procedures through the Salesforce UI, enabling faster and more efficient deployments.
Why Use Salesforce CLI and VS Code for Import/Export?
Transferring configurations manually can be time-consuming, especially when working with complex OmniStudio components. Using Salesforce CLI and VS Code allows you to:
- Quickly export and import OmniScripts and related components.
- Ensure consistency across environments (like from sandbox to production).
- Save time when migrating or collaborating on OmniStudio projects.
Here’s how you can export and import OmniScripts, DataRaptors, and Integration Procedures using Salesforce CLI.
Also Read: OmniScript Address Autocomplete with Google Places Api
Step-by-Step Guide: Exporting and Importing OmniScripts
Setting Up Salesforce CLI and VS Code
Before running any commands, ensure that:
- OmniStudio is enabled in your Salesforce org.
- Your VS Code is authorized with the Salesforce org that contains the OmniScript you wish to export.
You can authorize your Salesforce org using the following command:
sfdx force:auth:web:login -a org_alias
Exporting an OmniScript
To export an OmniScript from Salesforce, use the following Salesforce CLI command:
sfdx force:data:tree:export -q "SELECT IsMetadataCacheDisabled, IsTestProcedure, Description, OverrideKey, Name, OmniProcessKey, Language, PropertySetConfig, LastPreviewPage, OmniProcessType, ElementTypeComponentMapping, SubType, ResponseCacheType, IsOmniScriptEmbeddable, CustomJavaScript, IsIntegrationProcedure, VersionNumber, DesignerCustomizationType, Namespace, Type, RequiredPermission, WebComponentKey, IsWebCompEnabled,(SELECT Description, DesignerCustomizationType, Name, EmbeddedOmniScriptKey, IsActive, Type, ParentElementId, PropertySetConfig, SequenceNumber, Level, Id from OmniProcessElements) from OmniProcess where OmniProcessType='Omniscript' AND id='omniscript_id'" -u org_alias -p -d export_directory -p
Breaking Down the Command:
- -q: The SOQL query to fetch OmniScripts and their elements.
- -u org_alias: The alias for the Salesforce org you’re working with.
- -d export_directory: The directory where the OmniScript data will be saved.
- -p: Prompts for password if needed.
Important Notes:
- Replace omniscript_id with the OmniScript ID you wish to export.
- If you omit the id in the query, it will export all OmniScripts in the org.
Importing an OmniScript
Once the OmniScript is exported, you can import it into a different Salesforce org using this command:
sfdx force:data:tree:import -p ./export_directory/OmniProcess-OmniProcessElement-plan.json -u org_alias
What This Does:
- This command imports the OmniScript from the exported JSON file back into Salesforce.
- -p specifies the path to the exported JSON file.
- -u org_alias is the alias for the target Salesforce org.
Salesforce Official Documentation for Importing/Exporting OmniScripts
Exporting and Importing DataRaptors and Integration Procedures
The process for DataRaptors and Integration Procedures is similar to that of OmniScripts. The key difference lies in the SOQL query that you use to target these components.
Exporting DataRaptors
To export DataRaptors, modify the SOQL query to target these components:
sfdx force:data:tree:export -q "SELECT Id, SourceObject,ExpectedInputOtherData,ExpectedOutputJson,Description,ExpectedOutputXml,IsDeletedOnSuccess,IsProcessSuperBulk,OverrideKey,PreviewOtherData,SynchronousProcessThreshold,TargetOutputDocumentIdentifier,GlobalKey,Name,IsAssignmentRulesUsed,IsXmlDeclarationRemoved,XmlOutputTagsOrder,IsSourceObjectDefault,InputParsingClass,ExpectedOutputOtherData,PreviewSourceObjectData,OutputType,PreviewJsonData,IsRollbackOnError,BatchSize,ResponseCacheType,IsNullInputsIncludedInOutput,VersionNumber,OutputParsingClass,Type,IsErrorIgnored,ExpectedInputJson,ExpectedInputXml,RequiredPermission,PreviewXmlData,InputType,ResponseCacheTtlMinutes,TargetOutputFileName,IsFieldLevelSecurityEnabled,PreprocessorClassName, (SELECT Id,MigrationPattern,InputObjectQuerySequence,FormulaResultPath,FormulaSequence,LinkedFieldName,IsDisabled,MigrationCategory,MigrationType,OutputFieldName,MigrationValue,FilterGroup,LinkedObjectSequence,GlobalKey,Name,OutputCreationSequence,DefaultValue,LookupReturnedFieldName,IsRequiredForUpsert,MigrationProcess,FilterDataType,InputObjectName,FormulaExpression,LookupObjectName,MigrationAttribute,MigrationGroup,FilterValue,FilterOperator,InputFieldName,MigrationKey,IsUpsertKey,LookupByFieldName,OutputFieldFormat,TransformValueMappings,OutputObjectName FROM OmniDataTransformItems) FROM OmniDataTransform" -u org_alias -p -d export_directory -p
Importing DataRaptors
Similarly, to import DataRaptors use:
sfdx force:data:tree:import -p ./export_directory/OmniDataTransform-OmniDataTransformItem-plan.json -u org_alias
Salesforce Official Documentation for Importing/Exporting DataRaptors
Exporting Integration Procedures
sfdx force:data:tree:export -q "SELECT IsMetadataCacheDisabled, IsTestProcedure, Description, OverrideKey, Name, OmniProcessKey, Language, PropertySetConfig, LastPreviewPage, OmniProcessType, ElementTypeComponentMapping, SubType, ResponseCacheType, IsOmniScriptEmbeddable, CustomJavaScript, IsIntegrationProcedure, VersionNumber, DesignerCustomizationType, Namespace, Type, RequiredPermission, WebComponentKey, IsWebCompEnabled,(SELECT Description, DesignerCustomizationType, Name, EmbeddedOmniScriptKey, IsActive, Type, ParentElementId, PropertySetConfig, SequenceNumber, Level, Id from OmniProcessElements) from OmniProcess where OmniProcessType='Integration Procedure' AND id='integration_procedure_id'" -u org_alias -p -d export_directory -p
Replace the following:
org_alias
The org from where you’re exporting the Integration Procedure.
export_directory
The directory in the project where the exported JSON file is stored.
integration_procedure_id
The ID of the Integration Procedure that you want to export.
Importing Integration Procedures
sfdx force:data:tree:import -p ./export_directory/OmniProcess-OmniProcessElement-plan.json -u {org_alias}
Replace the following:
org_alias
The org from where you’re exporting the Integration Procedure.
export_directory
The directory in the project where the exported JSON file is stored.
Salesforce Official Documentation for Importing/Exporting Integration Procedures
Important Considerations
- SFDX Commands Deprecation: Currently, Salesforce CLI (SFDX) commands are fully supported and work well for OmniStudio components, including OmniScripts, DataRaptors, and Integration Procedures. However, SFDX commands are planned to be deprecated in the future and will be replaced by Salesforce CLI (SF CLI) commands. Stay updated on this change to avoid potential issues down the road.
- Exporting/Importing All Components: If you wish to export all OmniScripts, DataRaptors, or Integration Procedures, you can omit the id in your SOQL query. This will export all components of that type in the org.
Here is the official Salesforce documentation link to include in your article for best practices and detailed help on deploying OmniStudio components with Salesforce CLI:
Salesforce Official Documentation:
Deploy and Retrieve OmniStudio Components Using Salesforce CLI
https://help.salesforce.com/s/articleView?id=xcloud.os_omnistudio_standard.htm&type=5
You can reference this as the authoritative guide for exporting/importing OmniScripts, DataRaptors, and Integration Procedures using Salesforce CLI and VS Code.
Conclusion
With VS Code and Salesforce CLI, you can efficiently export and import OmniScripts, DataRaptors, and Integration Procedures between Salesforce orgs. This process streamlines deployments, saves time, and ensures consistency across environments.The commands shown here are currently based on SFDX but will eventually be replaced with SF CLI commands. It’s always a good idea to stay updated with Salesforce’s roadmap to ensure your processes remain future-proof. Keep visiting https://2creative.ca/ to keep yourself updated with latest salesforce updates and news.