How do i copy values of two system field into a custom field.

Deleted user February 15, 2016

How do i copy values of two system field into a custom field. Say for eg. text field type custom field "Final Status" needs to be updated like this: "<status value> - <resolution value>" for the value of system field Status and Resolution. I cannot do it manually since there are more than 1500 issues in my project, please suggest.

4 answers

0 votes
Deleted user February 16, 2016

@Fidel Castro Armario

Thanks a lot FIdel for your pointer and it worked indeed !

 

Thanks Nic and Vasiliy for taking time to look after my query, unfortunately we don't have script runner plugin at the moment but certainly your response gives me workaround to use when i wouldn't have workflow toolbox Plugin.

0 votes
Fidel Castro
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 15, 2016

Hi Pratiyush,

You can do it using "Copy a parsed text to a field" post-function (provided by JIRA Workflow Toolbox plugin) with the following configuration:

Captura de pantalla 2016-02-16 a las 10.38.30.png

Note that:

  • %{00016} is field code for Issue Status
  • %{00028} is field code for Resolution

In order to execute the transition on your 1500 issues at once, I recommend you to do the following:

  1. Create a reflexive temporary transition (same origin and destination status). Let's call it "Temporary Transition"
  2. Add "Copy a parsed text to a field" post-function with the former configuration to "Temporary Transition".
  3. Do a search in JIRA that returns your 1500 issues, and then use bulk change functionality to execute transition "Temporary Transition" in all of them.
  4. Remove "Temporary Transition" from your workflow.

 

Your "Temporary Transition" should look like this:

Captura de pantalla 2016-02-16 a las 10.38.52.png

 

Another possible solution is to use "Write field on issues returned by JQL query" (provided by JIRA Workflow Toolbox plugin) with the following configuration:

Captura de pantalla 2016-02-16 a las 10.59.41.png

Regards,

Fidel

0 votes
Vasiliy Zverev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 15, 2016

Here is code example to copy one custom filed value to another. You can modify it and run via Script console provided Script Runner Plugin.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.project.Project

/**
 * Move date value from one custom field to another
 */

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
CustomField dateFrom = customFieldManager.getCustomFieldObjectByName("Дата выдачи согласованного MD.050");
if(dateFrom == null)
        return "field for date from not found"

CustomField dateTo = customFieldManager.getCustomFieldObjectByName("Дата окончания");
if(dateFrom == null)
    return "field for date from not found"

//Loop issues and update
IssueManager issueManager = ComponentAccessor.getIssueManager();
for(Project project: ComponentAccessor.getProjectManager().getProjectObjects())
    for(MutableIssue issue: issueManager.getIssueObjects( issueManager.getIssueIdsForProject())){
        issue.setCustomFieldValue(dateTo, issue.getCustomFieldValue(dateFrom))
        issueManager.updateIssue(ComponentAccessor.getJiraAuthenticationContext().getUser().getDirectoryUser(), issue, EventDispatchOption.ISSUE_UPDATED, false)
    }
0 votes
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 15, 2016

You'll need a bit of code to do that.  There are a load of add-ons that can do this in varying ways.

If it were up to me, I'd use the Script Runner to create a "scripted field" that concatenates those two together, but that's not quite the same as poking the calculated value into a custom field (with a bit more work, you can still do it with Script Runner)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events