Copy linked issues to a custom field (as a string)

Nikola Bornová May 24, 2016

On specific transition, I would like to copy all issue links of specific type to a custom field (copy summary + key of linked issues into custom field).

It would be used for user to acknowledge/accept current state issue links (in this case it's for "inventory" project - user would acknowledge all SW installed in his PC, which is done by connecting issue for his HW with issues for SW licenses)

Would this possible via ScripRunner?

Thank you smile

1 answer

1 accepted

1 vote
Answer accepted
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.
May 27, 2016

Hi Nikola,

It can be done very easily using "Read fields from linked issues or subtask" post-function provided by JIRA Workflow Toolbox.

You should use a configuration similar to this one:

conf-1.png

conf-2.png

conf-3.png

Configuration shown copies the fields Summary and Issue key of all Bug, New Feature and Task issues linked to current one with "is blocked by", "is cloned by" or "is duplicated by" issue link types into current issue's "Long Text" custom field.

Pairs SummaryIssue key are separated by comma character. An example of the value obtained at "Long Text" custom field might be:

Printer not working - CRM-34, Feature for uploading files - CRM-23, Compatibility with IE11 - CRM-54

Please, let me know whether this meets your requirements or not. I'm pretty sure I can implement your requirements using JIRA Workflow Toolbox.

Regards,

Fidel

Nikola Bornová June 10, 2016

Tried it, it works.

Sir, I think you have a new customer (if I'll get budget approval for it) smile  I was looking at Workflow Toolbox for a long time and this was the final weights on the scale.

Just one quick question - is it possible to put between the values in result line breaks instead of commas? It would be better arranged this way.

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.
June 10, 2016

Thanks Nikola. I wish you become a user of JIRA Workflow Toolbox. I'm sure you will find many uses for it in your workflows.

I explain you how to replace comma separator with a new line character:

1) Select Ephemeral string 1 in parameter target field of  "Read fields from linked issues or subtask" post-function, instead of Long Text custom field.

2) Insert "Copy a parsed text to a field" post-function after "Read fields from linked issues or subtask" post-function with the following configuration:

  • Target field: Long Text
  • Parsing mode: advanced
  • Text to be parsed: 
replaceAll(%{00061}, ",(?=(\\s.+\\s-\\s[A-Z]+-[0-9]+(,|$)))", "\\n")

 

Explanation:

What we have done is to store temporarily the initial value obtained from "Read fields from linked issues or subtask" post-function into auxiliary field "Ephemeral string 1", and then we store its content in the definitive custom field (in the example "Long Text" custom field), after having replaced the commas after issue keys with line breaks (i.e., \n characters). to do it we use function replaceAll().

We use a complex regular expression instead of simply a comma character (,), because we might have commas within the summaries that we shouldn't replace with line breaks.

Nikola Bornová June 14, 2016

Hi, thanks for the answer, unfortunately something is wrong. The parsed text is inserted in the target field but the replaceAll doesn't replaced the comma with line break.

See the pictures of the setup and result after the transition that used it.

 

toolbox 0.png

 

toolbox 1.png

 

 

toolbox 2.png

Suggest an answer

Log in or Sign up to answer