Parsing JIRA Issue keys from field and then appending them to linked issue Summary field

Issue #335 resolved
JamieS created an issue

I've been trying to do something with your plugin but I'm either not using the post-functions correctly or I'm not getting the syntax right. I've reviewed the syntax specification for the parser but when I try to use it within the "Copy a parsed text to a field" post function it always shows errors when I save the post function.

Here is what I am trying to do...

I have two issues, the main issue (A) and a linked issue (B). I have a customer field "Related Work" on issue A which I want to parse all of the JIRA issue keys from and then append them on to the Summary field of issue B. I will need to first find all issue keys currently in the issue B Summary field and remove them.

Based on the syntax specification I believe I need the following logic:

// Clear all JIRA Issue keys from within the linked issue Summary field with replaceAll( fieldValue(%{00000}, linkedIssues()), "[a-zA-Z]+-[0-9]+", "" )

// Append all JIRA Issue keys found in the Related Work custom field to the linked issues Summary field. append( fieldValue(%{00000}, linkedIssues()) , findPatternIgnoreCase(%{13820},"[a-zA-Z]+-[0-9]+") )

Is this even possible to do? If so, what might I be doing wrong? Any help on this would be greatly appreciated.

Comments (4)

  1. Fidel Castro Armario repo owner

    Hi Jamie,

    You should use "Write field on linked issues or subtasks" with the following configuration:

    conf-1.png conf-2.png conf-3.png conf-4.png conf-5.png

    Source value is:

    replaceAll(^%{00000}, "\\s*,?\\s*[a-zA-Z]+-[0-9]+", "") + " " + toString(findPattern(%{nnnnn}, "[a-zA-Z]+-[0-9]+"))
    

    replacing nnnnn with field code of Related Work custom field.

    Note that ^%{00000} is field code for Summary in linked issues.

    Issue keys will be appended at the end of the Summary of linked issues as a comma separated list of issue keys.

  2. JamieS reporter

    Works great Fidel! I really appreciate the quick response.

    One tweak I need to make was to add the trim() function around the replaceAll, otherwise everytime the post function got called another space was getting appended to the Summary field.

    trim(replaceAll(^%{00000}, "\\s*,?\\s*[a-zA-Z]+-[0-9]+", "")) + " " + toString(findPattern(%{nnnnn}, "[a-zA-Z]+-[0-9]+"))
    
  3. Log in to comment