This example shows how to create or update a Zendesk Organization based on an entity synchronized through Exalate. In this case, we are synchronizing a Salesforce Account → Zendesk Organization.
The same approach can be adapted for other Exalate supported platforms, such as Jira Cloud, Jira Data Center, ServiceNow, Azure DevOps, and others. The important part is that the required entity information is available in the replica.
Script Overview
if (replica.customKeys."Entity Type" == "Account") {
In this example, "Entity Type" is added to the replica on the Salesforce side so the destination can distinguish Account synchronization events from other entities.
- Build the Zendesk Organization: The script creates the request body using information received through the replica:
def body = [
organization: [
name : replica.name?.toString(),
external_id: replica.key?.toString(),
organization_fields: [
sf_account_id : replica.key?.toString(),
migrated_account_id: replica.customKeys."Migrated AccID"?.toString()
]
]
]
Here, the Salesforce Account ID is used as the Zendesk external_id. Custom Zendesk organization fields can also be populated using values received through the replica.
- Create or Update the Organization: Finally, the Zendesk API is called using Exalate’s
httpClient:
def response = httpClient.post(
"/api/v2/organizations/create_or_update.json",
JsonOutput.toJson(body)
)
Using Zendesk’s create_or_update endpoint allows the same script to create the organization when it does not exist or update it when an organization with the corresponding external_id already exists.
Final Solution
Source side – Salesforce
The required Account information needs to be included in the replica. For example:
if(entity.entityType == "Account") {
replica.customKeys."Entity Type" = "Account"
replica.key = entity.Id
replica.name = entity.Name
replica.customKeys."Migrated AccID" = entity.Migrated_Account_ID__c
}
Adjust the Salesforce field/API names according to your configuration.
Destination side – Zendesk
if (replica.customKeys."Entity Type" == "Account") {
def body = [
organization: [
name : replica.name?.toString(),
external_id: replica.key?.toString(),
organization_fields: [
sf_account_id : replica.key?.toString(),
migrated_account_id: replica.customKeys."Migrated AccID"?.toString()
]
]
]
def response = httpClient.post(
"/api/v2/organizations/create_or_update.json",
JsonOutput.toJson(body)
)
}
Notes
- This example uses Salesforce Account → Zendesk Organization, but the same pattern can be adapted to other Exalate-supported platforms by changing the source-side data added to the replica.
sf_account_idandmigrated_account_idare custom Zendesk organization fields and should be replaced with the field keys from your own Zendesk configuration.- The value used as
external_idshould uniquely identify the source entity. This is what allows Zendesk’screate_or_updateendpoint to update the existing organization instead of creating duplicates.
Version
5.36.0