We are currently syncing tickets from JSM to Jira.
But we would like assignee field to be populated in the service desk projects based on assignee from Jira.
If the assignee in Jira is not an agent, then the field can remain blank, else it must be populated.
We tried using the normal script for assignee field:
replica.assignee = issue.assignee
issue.assignee = replica.assignee
This throws an error whenever the Exalate fails to find the user to assign to the tickets or when the user does not have proper permissions in the project.
Hence, we want to go with the mentioned solution.
Please let me know if this is possible to achieve or if there are any alternatives to achieve this.
You can definitely achieve your goal by customizing your sync rules to only set the assignee if the user is an agent in the JSM project. The key is to check if the user exists, is active, and (optionally) is a service desk agent before assigning. If not, you can leave the assignee field blank.
Here’s how you can approach this:
Check if the user exists and is active:
Use the nodeHelper.getUser (for Jira Cloud) or nodeHelper.getUserByEmail/nodeHelper.getUserByUsername (for on-prem) methods to fetch the user.
Example for Jira Cloud:
def localAssignee = nodeHelper.getUser(replica.assignee?.key)
if(localAssignee?.active) {
// Optionally, check if user is an agent here
issue.assignee = localAssignee
} else {
issue.assignee = null
}
Example for Jira on-prem:
def localAssignee = nodeHelper.getUserByEmail(replica.assignee?.email)
if(localAssignee?.active) {
// Optionally, check if user is an agent here
issue.assignee = localAssignee
} else {
issue.assignee = null
}
Check if the user is a JSM agent:
Exalate’s built-in scripting does not directly expose a method to check if a user is a JSM agent. However, you can maintain a list of agent emails or accountIds and check against it:
You’ll need to keep the agentEmails list updated with your actual agents.
Why your current script fails:
The error occurs because Exalate tries to assign a user who either doesn’t exist or lacks permissions. The above approach avoids this by only assigning if the user is valid and (optionally) an agent.
You can find more details and examples in the Exalate documentation: