How to deploy Conga Composer configuration using Salesforce CLI plugins

I sometimes help on Cloudity projects as Release Manager, and I had to deploy Conga Composer configuration using CI/CD.
When I saw the hardcoded record Ids in the url of custom buttons, I started to get a little bit crazy , because creating dependencies between data and metadata is a very bad practice that we teach our juniors to avoid !
Then Conga contacted me and I had a very interesting session with Rodolphe Malaguti, who explained to me everything I needed to know to configure, collect and deploy items necessary to transfer Conga Composer configuration from one org to another, using Git-based deployments.
Composer configuration
You do not need to use hardcoded Ids, use Conga Keys !
On every conga configuration record (Template, Query, Email Template, Solution), you have an auto-populated field named Key.
Use it in your Conga custom buttons and Conga Solutions !

Retrieve Conga Composer Items
Conga Configuration is the association of 3 different types of elements.
- Metadata: WebLinks (Custom Buttons defined on objects), Flexipages where Custom Buttons or Conga Solutions Component are embedded
- Data: Records corresponding to objects: APXTConga4__Conga_Template__c, APXTConga4__Conga_Merge_Query__c, APXTConga4__Conga_Email_Template__c, APXTConga4__Conga_Solution__c (there are probably more, but I don’t need them on my project: please comment this article to complete :) )
- Files: Word templates associated to APXTConga4__Conga_Template__c records

(1) Retrieve Metadata
We won’t explain you how to retrieve/deploy metadatas: use the tool you prefer for that ! (sfdx-hardis, Salesforce CLI, DevOps Center, 3rd party vendors DevOps tools…)

- Weblinks
- Flexipages with Conga custom buttons or embedding Conga Solutions Lightning component
(2) Export Conga records
You can use free and open-source tools sfdx-hardis and SFDMU to retrieve all Conga records.
If you don’t have sfdx-hardis on your computer, please follow the installation instructions in the video tutorial
Click on menu Data & Files -> Create Data Import/Export Configuration, then select template CongaComposer.

If will generate a data folder with an export.json file containing the following text.
{
"sfdxHardisLabel": "Conga Configuration",
"sfdxHardisDescription": "Will export/import Conga config (Templates, Queries, Email Templates, Solutions)",
"objects": [
{
"query": "SELECT all FROM APXTConga4__Conga_Template__c",
"operation": "Upsert",
"externalId": "APXTConga4__Key__c"
},
{
"query": "SELECT all FROM APXTConga4__Conga_Merge_Query__c",
"operation": "Upsert",
"externalId": "APXTConga4__Key__c"
},
{
"query": "SELECT all FROM APXTConga4__Conga_Email_Template__c",
"operation": "Upsert",
"externalId": "APXTConga4__Key__c"
},
{
"query": "SELECT all FROM APXTConga4__Conga_Solution__c",
"operation": "Upsert",
"externalId": "Name"
}
]
}
Click on menu Data & Files -> Export Data from org with SFDMU , and when prompted, select CongaComposer data project.

If you are on a CI/CD project, stage and commit export.json + the generated .csv files.
(3) Export template files
You can again use free and open-source tool sfdx-hardis to retrieve all template files.
Click on menu Data & Files -> Create Files Import/Export Configuration, then select template CongaTemplates.

It will generate a folder CongaTemplates with the following export.json file.
{
"sfdxHardisLabel": "Conga Template files for Conga configuration",
"sfdxHardisDescription": "Export attachments related to conga templates",
"soqlQuery": "SELECT Id,Name,APXTConga4__Key__c FROM APXTConga4__Conga_Template__c",
"fileTypes": "all",
"outputFolderNameField": "APXTConga4__Key__c",
"outputFileNameFormat": "title",
"overwriteParentRecords": true,
"overwriteFiles": true
}
Click on menu Data & Files -> Export Files from org, and when prompted, select CongaComposer data project.
If you have multiple word files, delete all of them except the most recent one, which is corresponding to the template file you want to use.

If you are on a CI/CD project, stage and commit export.json + the downloaded .doc / .docx files.
Deploy Conga Composer items
Now you have collected all items related to conga configuration (Metadatas, records and files) you can now import them in the target org !
(1) Deploy Metadata
Again, we won’t explain you how to retrieve/deploy metadatas: use the tool you prefer for that ! (sfdx-hardis, Salesforce CLI, DevOps Center, 3rd party vendors DevOps tools…)
- Weblinks
- Flexipages with Conga custom buttons or embedding Conga Solutions Lightning component
(2) Import Conga records
Click on menu Data & Files -> Import Data to org with SFDMU , and when prompted, select CongaComposer data project.

You can automate this action in your CI/CD workflows using the following command line.
sfdx sfdmu:run --sourceusername csvfile --targetusername YOUR_TARGET_USERNAME -p scripts/data/CongaConfig --noprompt
Note: Add — canmodify option if the target is on a production org
(3) Import template files
Click on menu Data & Files -> Import files into org , and when prompted, select CongaTemplates file project.

You can automate this action in your CI/CD workflows using the following command line.
sfdx hardis:org:files:import --path scripts/files/CongaTemplates --targetusername YOUR_TARGET_USERNAME
Conclusion
With Conga Keys, sfdx-hardis & SFDMU, you can easily export then import Conga configuration from one org to another, and automate it within your CI/CD pipelines !
