Azure Devops always defaulting t

It seems my azure devops incoming sync is always requiring to create a ‘Task’ work item type when I have set up specific parameters to create different work items based on a ZenDesk custom field called Escalation Type.

Here is my incoming sync code:

String remotetype = replica.customFields.“Escalation Type”?.value?.value

Map typemap = [
“bug”: “Bug”,
“fix script”: “Task”,
“crystal”: “PBI Task”,
“form change”: “PBI Task”,
“quoted form change”: “PBI Task”
]

// Normalize the remote type to handle case sensitivity, trim spaces, and replace underscores with spaces
def normalizedType = remotetype?.trim()?.toLowerCase()?.replace(‘_’, ’ ')
def mappedType = typemap[normalizedType]

// Fetch and log the expected values for the Activity field
if (firstSync) {
try {
def activityFieldValues = nodeHelper.getFieldValues(“Activity”)
debug.info(“Allowed values for Activity field: ${activityFieldValues}”)
} catch (Exception e) {
debug.error(“Failed to fetch allowed values for Activity field: ${e.message}”)
}

// Log unmapped escalation types for debugging purposes
if (!mappedType) {
debug.error(“Unmapped escalation type: ${remotetype}”)
// Optionally add a label to indicate an unmapped type
workItem.labels += [“Unmapped Escalation Type: ${remotetype}”]
}

// Set project key and determine work item type based on mapping or default to Task
workItem.projectKey = “EniteoSource”
workItem.typeName = nodeHelper.getIssueType(mappedType)?.name ?: “Task”

// Set default value for Activity field only for Task work item type
if (workItem.typeName == “Task”) {
workItem.customFields.“Activity”?.value = “Non-Code”
}
}

workItem.summary = replica.summary
workItem.description = replica.description
workItem.attachments = attachmentHelper.mergeAttachments(workItem, replica)
workItem.comments = commentHelper.mergeComments(workItem, replica)
workItem.labels = replica.labels
workItem.priority = replica.priority

/*
Custom Fields (CF)
To add incoming values to an Azure DevOps custom field, follow these steps:
1/ Find the Field Name of the CF. You can also use the API name: How to Sync Work Item Fields Obtained through a REST API Call in Azure DevOps | Exalate Documentation
2/ Check how the value is coming over from the source side, by checking the “Entity Sync Status” of a ticket in sync and then selecting “Show Remote Replica”.
3/ Add it all together like this:
workItem.customFields.“CF Name”.value = replica.customFields.“CF Name”.value
*/

/*
Status Synchronization
For Status Syncing, we map the source status, to the destination status with a hash map. The syntax is as follows:
def statusMap = [
“remote status name”: “local status name”
]
Go to Entity Sync Status, put in the ticket key, and it will show you where to find the remote replica by clicking on Show remote replica:
def statusMap = [
“Backlog” : “To Do”,
“In Progress” : “Doing”,
“Done” : “Done”
]
def remoteStatusName = replica.status.name
workItem.setStatus(statusMap[remoteStatusName] ?: “Add a default status in these double quotes”)
*/

/*
Area Path Sync
This also works for iterationPath field

Set Area Path Manually
workItem.areaPath = "Name of the project\\name of the area"

Set Area Path based on remote side drop-down list
Change "area-path-select-list" to actual custom field name
workItem.areaPath = replica.customFields."area-path-select-list"?.value?.value

Set Area Path based on remote side text field
Change "area-path" to actual custom field name
workItem.areaPath = replica.customFields."area-path".value

*/

// Exalate API Reference Documentation: Exalate API Reference Documentation

The reason this is a problem is that the Task type work item has a field requirement called Activity. It seems that no matter what Escalation Type value I have, the sync or ADO is trying to create a Task type work item and it’s failing. Any thoughts on how I can adjust the incoming sync code to ONLY create a Task work item based on the value of fix script and then set the Non-code value for Activity from that?

This looks to be my only hurdle at this point.

Sidenote: does anyone know how to make an API call to pull in all the values from a custom field in ADO?

Hi @jpremick,

It seems that the mapping logic always defaults to creating a “Task” because there is an issue with the script.

Could you share the JSON of customFields.“Escalation Type” that is found in the replica of the issue you are trying to synchronize? You can view the replica details in the Entity Sync status panel. If the entity is synced, you can view the local replica by clicking the Show local replica button and the remote replica by clicking the Show remote replica button.

Best regards,
Javier Pozuelo

This is the outgoing sync code coming from ZenDesk:

replica.key = issue.key
replica.assignee = issue.assignee
replica.reporter = issue.reporter
replica.summary = issue.summary
replica.description = issue.description
replica.type = issue.type
replica.labels = issue.labels
replica.attachments = issue.attachments
replica.comments = issue.comments

replica.status = issue.status
//customFields
replica.customFields.“Story Title” = issue.customFields.“Story Title”
replica.customFields.“Severity of Issue” = issue.customFields.“Severity of Issue”
replica.customFields.“Customer Story” = issue.customFields.“Customer Story”
replica.customFields.“Steps to Reproduce” = issue.customFields.“Steps to Reproduce”
replica.customFields.“Acceptance Criteria” = issue.customFields.“Acceptance Criteria”
replica.customFields.“Is there a work around? If so, what is it?” = issue.customFields.“is there a work around? if so, what is it?”
replica.customFields.“Escalation Type” = issue.customFields.“Escalation Type”
// Fetch org name
def org = httpClient.get(“/api/v2/organizations/${issue.organization_id}”)?.organization

replica.organizationName = org?.name
replica.codeVersion = org?.organization_fields?.code_version

// replica.customFields.“Customer Topic” = issue.customFields.“Customer Topic”

/*
Custom Fields (CF)
How to send any field value from the source side to the destination side.
1/ Add the value to the replica object. Use the Display Name from the field.
2/ Uncomment this next statement out and change accordingly:
replica.customFields.“CF Name” = issue.customFields.“CF Name”
*/

// Exalate API Reference Documentation: Exalate API Reference Documentation

Hello @jpremick,

The replica is the copy of the information that is getting transferred to the destination side. You can find the replica in the Entity Sync status panel in the Exalate console, as seen below:

In the Entity Urn input, type the key of one of the Zendesk tickets you are attempting to synchronize and select “Local Replica”. After displaying the replica details, could you share the details of “Escalation Type” that are shown in the replica?

Best regards!