This article shows how to synchronize custom fields in Azure DevOps.
You can synchronize all standard custom fields including the following work item field types:
- Boolean (you can sync boolean fields into a number)
- Text (multiple lines) uses HTML
- Integer (number)
- Decimal (number)
- Date/Time
For more information, please read the work item fields and attributes in Azure DevOps documentation.
There are always two main configuration points: Outgoing sync, which is the sending side, and Incoming sync, which is the receiving side.
Outgoing Sync
To send the custom field data to add the custom field to the replica in the Outgoing sync.
issue.customFields is an array of custom fields. Every custom field contains a value or a set of values.
replica.customFields is empty.
The code below helps to add a custom field to a replica. Use this code in the Outgoing sync on the source side.
replica.customFields."Custom field displayName" = workItem.customFields."Custom field displayName"
Incoming Sync
The receiving side gets a replica and process it in the Incoming sync. For simple fields, you can just assign the value of the received custom field to any local field.
The replica.customFields is set by the remote Instance. The issue.customFields is your local custom field in Azure DevOps where you put the received data from the remote side.
This is an example of how to assign the value of the received custom field to the local custom field.
workItem.customFields."Local custom field displayName" = replica.customFields."Custom field displayName"?.value
How to Set a Field Value Manually?
You can set a value of the custom field directly in the Sync Rules. To do that you need to know the type of the custom field value.
The custom field value type depends on the type of the custom field itself. Each value type has different properties and fields that can be used during synchronization.
Below you can find supported field types and their value types.
Azure DevOps field types | Value on script |
---|---|
Date/Time | Date/Time or Date |
Integer | Number |
Decimal | Number |
Text(Multiple lines) | HTML |