Azure DevOps board is used to create a task or work item with a pre-defined or custom work item template. It can consist of multiple different types of fields like Text, Multi Text, Drop Down, Identity (People Picker), and Date Time.
If, as a developer, I need to extract all schema-defined drop-down values and need to sync with another system like the SharePoint Online List choice column.
Let's begin here with the creation of a work item and extraction using power automate.
- Resource Work Item type has the below layout, and the User can submit the detail as provided.
- Technical Skill i.e. drop-down field, has multiple values which need to extract.
Power Auotmate Steps
- Create a Recurrence flow,
- Add Azure DevOps action i.e. "Send an HTTP request to Azure DevOps".
- Relative URI: https://dev.azure.com/m365x6151710/Resource/_apis/wit/workitemtypes/Resource/fields?$expand=allowedValues&api-version=5.1
- Organization Name m365x6151710
- Project Name Resource
- Work Item Template Name Resource
- Add Variable of type Array and name as Technical Skill
- Add action "Apply to each" with an output of "Send an HTTP request to Azure DevOps" This will return all Azure DevOps work item fields
- Add a Condition to restrict the specific column i.e. "Custom.TechnicalSKill". (All Custom created columns should be treated as prefixes with Custom.)
- Once the Condition is satisfied, select the allowed values and set it back to the variable.
Let's execute the power automate to get the output.
Once the value gets into the defined array variable, set the array variable to the SPO choice field.
Add SharePoint action "Send an HTTP request to SharePoint"
- Site Address https://m365x6151710.sharepoint.com/
- Method POST URI
_api/web/lists/GetByTitle('Resource')/Fields/GetByID('69ca0e44-d80d-4e5b-9038-33fdc2e87c9d')
- Header
{
"accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose",
"X-HTTP-Method": "PATCH",
"IF-MATCH": "*"
}
- Body
{
"__metadata": {
"type": "SP.FieldChoice"
},
"Choices": {
"__metadata": {
"type": "Collection(Edm.String)"
},
"results": @{variables('TechnicalSkill')}
}
}
https://m365x6151710.sharepoint.com/_api/web/lists/getbytitle('Resource')?$select=schemaXml
Let's execute the power automate to get the output