/
How to transition from JIRA Metadata - View project metadata fields to Workflow Postfunctions

How to transition from JIRA Metadata - View project metadata fields to Workflow Postfunctions

This page focuses on the following use case.

Up to version 5.0, the metadata of a project was displayed by using “JIRA Metadata - View project metadata field“ at some Jira issues.

You want to change it to “Text Field (single line)” in your role as Jira Administrator.

Example: In the project there is the metadata SAP cost center and this should be displayed in the activity.

New Text Field (single line) and Workflow Postfunction

First we need to create a new field and fill it automatically when the user creates a Jira issue.

  • Create the field of type “Text Field (single line)” and place it on a screen

    • Adding custom fields | Administering Jira applications Data Center 10.4 | Atlassian Documentation

  • Add the “Metadata : Copy Project Metadata Value Post Function“ to the create transition

    • Advanced workflow configuration | Administering Jira applications Data Center 10.4 | Atlassian Documentation

    • How-to use Metadata Workflow Postfunctions

For new Jira issues, the cost center is now transferred from the project.

Transfer the metadata value for existing issues

Next we transfer project metadata for existing Jira issues.

You need version 5.1 or newer for this operation.

  1. Search for all issues to which existing metadata should be transferred.

    In the url there is a parameter jql remember/copy this parameter.

  2. Identify the Id of the newly created field. In our example it is customfield_10510

  3. Invoke the following URL

    1. YOUR_SERVER_URL/rest/metadata/1.0/admin/copyProjectMetadata?metadataKey=SAP%20cost%20center&max=100&fieldId=customfield_10510&jql=THE_COPIED_JQL
      e.g. YOUR_SERVER_URL/rest/metadata/1.0/admin/copyProjectMetadata?metadataKey=SAP%20cost%20center&max=100&fieldId=customfield_10510&jql=project%20%3D%20"Test%20Core%20Std%20Fields"%20AND%20"SAP%20cost%20center"%20is%20EMPTY

After a few seconds the following is displayed

{
"messages": [
{"message": "jql total issue count: 56"},
{"message": "jql max processed: 100"}
]
}

If any problems have occurred, the output may be different.

As you can see here, the metadata value has been transferred.

 

Related content