The Exalate team will be on holiday for the coming days - returning Jan 4
Enjoy & stay safe

Introduction


You use Exalate to integrate Salesforce with Jira Cloud.


In this tutorial, we will delve into the script mode of Exalate to demonstrate how comments from Salesforce can be integrated and displayed in Jira Cloud in a personalized manner.


One key aspect to consider is that Salesforce utilizes unique user and account identifiers, commonly known as IDs. To ensure accurate integration, we will employ Salesforce Query Language (SoQL) to retrieve the associated email address for a particular user.


Moving on to Jira Cloud, we will modify the proxy user based on the retrieved email address. This crucial step ensures that the comment in Jira Cloud is attributed to the corresponding user who originally created it in Salesforce. By dynamically assigning the comment creator, the integration becomes more seamless and representative of the original contributors.


However, it is important to note that the prerequisite for this integration is that the email address of the user must be identical in both the Salesforce and Jira Cloud instances.
This requirement establishes a reliable connection point for Exalate to match and synchronize the data effectively.



The code


Outgoing Sync Salesforce
if(entity.entityType == "Case") {
replica.key            = entity.Id
replica.summary        = entity.Subject
replica.description    = entity.Description
replica.comments       = entity.comments
replica.attachments    = entity.attachments
replica.Status         = entity.Status


//Retrieving the email from the last comment 
  def the_id_variable = entity.Id

def res = httpClient.get("/services/data/v54.0/query?q=SELECT+Body%2C+CreatedById%2C+CreatedBy.Email+FROM+CaseFeed+WHERE+ParentId=%27${the_id_variable}%27+ORDER+BY+CreatedDate+DESC")

replica.res = res
}





Incoming Sync Jira Cloud
if (firstSync) {
    issue.projectKey  = "MAT"
    // Set the same issue type as the source issue. If not found, set a default.
    issue.typeName    = nodeHelper.getIssueType(replica.type?.name, issue.projectKey)?.name ?: "Task"
}
issue.summary      = replica.summary
issue.description  = replica.description
issue.attachments  = attachmentHelper.mergeAttachments(issue, replica)
issue.labels       = replica.labels



replica.addedComments.each { it.executor = nodeHelper.getUserByEmail("${replica.res.records[0].CreatedBy.Email}") }
issue.comments = nodeHelper.toMarkDownComments(commentHelper.mergeComments(issue, replica, { it }))
}













Questions