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 fieldSet 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?