Copy Value from Subtask of Story1 into Story2

Issue #381 resolved
Bharath Kumar created an issue

Hi Fidel,

In our company Jira Instance, we have stories automatically created for the epic based on the components that are selected, lets says we selected component1, and component2 for a epic as we move one transition ahead 2 stories, Story for component1 and Story for component2 are created.

Now we also have an other story linked to the epic which has the same number of subtasks based on the selected components that is this story will have subtasks, Subtask for component1 and Subtask for component2.

Also I have the below thing going on at the story

            Story        
       Field 1 = 1+5     
      Field 2 = 3+6 
 Story Total = 1+5+3+6

Sub-Task 1 Sub-task 2

Field 1 = "1" Field 1 = "5"
Field 2 = "3" Field 2 = "6"
Subtask1 Total = "4" Subtask2 Total = "11"

Now after all this stuff, my question here is I should be able to show the field value Subtask1 Total = "4" and Subtask2 Total = "11" in Story for component1 and Story for component2 are created.

Can this be achieved I need your help on this

Comments (25)

  1. Fidel Castro Armario repo owner

    Do you have only 1 Story associated with the Epic at the moment the Stories related with the components are created?

    How can I know which subtask and which Story is associated with a certain component? Using the value of field Components in the subtask and in the Story?

  2. Bharath Kumar reporter

    no there are two stories one for components and other a normal story which is called sizing story (where all the component sub-tasks are present)

  3. Fidel Castro Armario repo owner

    Please, answer the following questions:

    1) Do you share the same workflow for all the stories?

    2) Which is the value of field "Components" for the sizing story?

    3) Which is the value of field "Components" for the rest of Stories?

    4) Does the sizing story has subtasks? If the answer is "Yes", can they have the field "Components" set?

    5) Which is the value of field "Components" for the subtasks of the other Stories? Can it contain more than one component?

  4. Bharath Kumar reporter

    1) No, there are two story issue types one is Component Story and other is Sizing Story and both of them have different workflow.

    4)Yes the sizing story has subtasks, the components are set at the epic level based on the components set at the epic level the stories and subtasks are created. So your answer they are not set at the subtask level

    2,3 and 5) Since the components are set at the epic level, the value of the components are same for all the stories and subtasks

    I know all of this sounds a little confusing, please let me know if you still have any question I will answer all the questions.:)

  5. Fidel Castro Armario repo owner

    If all the Stories have the same value at field "Components", how do you know which Story corresponds to a specific component?

  6. Fidel Castro Armario repo owner

    Bharath, can you please attach the following screenshots of the issues you showed me in the video conference:

    • Sizing story: I want to see the names of the components, and how the names of the subtasks are composed.
    • One of the Component stories
    • The Epic issue.

    Thanks.

  7. Bharath Kumar reporter

    Hey Fidel,

    I have attached all the SS for your reference Component Story Epic Sizing Story Subtasks for sizing

    component story.jpg epic ss.jpg sizing story.jpg subtask for sizing.jpg

  8. Fidel Castro Armario repo owner

    Use the "Mathematical and date-time expression calculator" post-function in a transition of Component Story workflow using the following configuration:

    • Target field: Component Total
    • Formula:
    first(fieldValue({aaaaa}, filterByPredicate(subtasks(filterByIssueType(linkedIssues("is Epic of", linkedIssues("has Epic")), "Sizing Story")), ^%{00000} ~ %{00094})))
    

    replacing aaaaa with field code for Component Total custom field.

    Try it first in a transition different from "Create Issue". Once you confirm that it works correctly, then implement it in "Create Issue" transition (after "Creates the issue originally" post-function), and check if it also works correctly when the issue is created automatically by Create on transition add-on.

  9. Bharath Kumar reporter

    Not working, I even tried changing the component total to parents component total in the target field and that approach was also not working.

    I did the same thing that you suggested me to do, I created a post function in one of the transition other than the create issue.

    I tested the formula and it is not working, is there any work around.

  10. Fidel Castro Armario repo owner

    Let's do some debug. Please, add "Copy a parsed text to a field" post-function in a transition of Component Story with the following configuration:

    • Target field: New comment
    • Parsing mode: advanced
    • Text to be parsed:
    "Epic issue: " + toString(linkedIssues("has Epic")) + "\n Stories: " + toString(linkedIssues("is Epic of", linkedIssues("has Epic"))) + "\n Sizing Story: " + toString(filterByIssueType(linkedIssues("is Epic of", linkedIssues("has Epic")), "Sizing Story")) + "\n Subtasks: " + toString(subtasks(filterByIssueType(linkedIssues("is Epic of", linkedIssues("has Epic")), "Sizing Story"))) + "\n Selected Subtask: " + toString(filterByPredicate(subtasks(filterByIssueType(linkedIssues("is Epic of", linkedIssues("has Epic")), "Sizing Story")), ^%{00000} ~ %{00094})) + "\n Value: " + toString(fieldValue({00068}, filterByPredicate(subtasks(filterByIssueType(linkedIssues("is Epic of", linkedIssues("has Epic")), "Sizing Story")), ^%{00000} ~ %{00094})))
    

    Now, execute the transition manually in a Component Story. It will create a comment in the issue. Please, share with me the content of this comment.

  11. Bharath Kumar reporter

    Thanks for the reply below is the screenshot and also the content of the result of transition

    Epic issue: ISPDQ-402

    Stories: ISPDQ-403, ISPDQ-407, ISPDQ-408, ISPDQ-409

    Sizing Story: ISPDQ-403

    Subtasks: ISPDQ-404, ISPDQ-405, ISPDQ-406

    Selected Subtask:

    Value:

    Copy parsed text - SS.jpg

  12. Fidel Castro Armario repo owner

    Try the following formula instead:

    first(fieldValue({aaaaa}, filterByPredicate(subtasks(filterByIssueType(linkedIssues("is Epic of", linkedIssues("has Epic")), "Sizing Story")), matches(^%{00000},  ".*\\Q" + %{00094} + "\\E.*"))))
    

    replacing aaaaa with field code for Component Total custom field.

  13. Bharath Kumar reporter

    wowwwwww that works perfect!!!!!!!!!!!!!!

    Now when I make changes to the values in the subtasks and come back and refresh the component story, now should I create a reflexive transition here in the component story and add the same post function in that transition so that when ever we change the values in the sub task, it would be easy to run the reflexive transition so that it can get the updated values on the component story.

    What would you suggest which will be the best way.

    Once again thank you soo much I dint expect that this can be achieved.

  14. Fidel Castro Armario repo owner

    I think that last question has relation with issue #369. You should add the following 2 post-function to transitions "Edit special fields" and "Create Issue" in subtask's workflow:

    1) "Copy a parsed text to a field" post-function witht he following configuration:

    • Target field: *Ephemeral string 1
    • Parsing mode: advanced
    • Text to be parsed:
    toString(filterByPredicate(linkedIssues("is Epic of", linkedIssues("has Epic", %{00041})), matches(%{00000},  "^\\Q" + ^%{00094} + "\\E.*")))
    

    2) "Write field on issues returned by JQL query" post-funcion with the following configuration:

    • Select a source type: math or date-time expression
    • Source: a formula like {aaaaa} + {bbbbb} + ... + {zzzzz} where aaaaa, bbbbb, ... are the field codes of the fields to be summed to calculate "Component Total". Here we don't use the the value of "Component Total" directly because I'm assuming that you are also calculating the value of that field in this same transition, and the updated value will not be available for post-functions until transition execution has finished.
    • JQL Query:
    issuekey in (%{00061})
    

    note that %{00061} is field code for Ephemeral string 1

    You should insert the 2 post-functions so that post-function 1 is executed before post-function 2. In Create Issue transition you should execute both post-functions AFTER post-function "Creates the issue originally".

  15. Bharath Kumar reporter

    Here is the configuration of the "Edit special fields" transition and the order in which all the post functions are places in the issue.

    edit special fields transition.jpg

  16. Fidel Castro Armario repo owner

    Hi Bharath,

    You should add to transition "Edit special fields" the 2 post-functions I described you in my previous post, i.e., "Copy a parsed text to a field" and "Write field on issues returned by JQL query" in that same order.

    Once you have done it, when you will edit your fields in a subtasks executing transition "Edit special fields", the value of field "Component Total" will be automatically updated in the corresponding Component Story.

  17. Bharath Kumar reporter

    How can I copy a field value from epic ( the field is a normal text field ) onto the story and subtasks that are linked to the epic??

  18. Fidel Castro Armario repo owner

    It depends on where do you want to execute the post-functions to do it. Do you want to execute a transition in Epic issue to copy the value of a field to:

    1) All the tasks linked to it (any issue type) 2) Tasks linked to it with type Story 3) All its direct subtasks. 4) All the subtasks of tasks linked to it (All issue types, or only Stories?)

    Please, tell me which is the correct option.

    Maybe, you want to execute the post-functions in the Story or subtasks.

  19. Bharath Kumar reporter

    I have a field called "Impact description" which I fill when I am creating a Epic.

    I also have a field called "Description" in a Story that is automatically created during one of the epic transitions, I want to copy the value Impact Description of Epic into Description field of Story.

    Also I have the same "Description" field in the subtasks which are also automatically created when the story is created I want to copy the same Impact Description of Epic into Description field of Subtask

  20. Fidel Castro Armario repo owner

    You have to use 2 post-functions in a transition of your Epic's workflow:

    1) "Copy a parsed text to a field" with the following configuration:

    • Target field: Ephemeral string 1
    • Parsing mode: advanced
    • Text to be parsed:
    toString(linkedIssues("is Epic of") UNION subtasks(linkedIssues("is Epic of")))
    

    2) "Write field on issues returned by JQL query" with the following configuration:

    • Select a source type: field in current issue
    • Source field: Impact description
    • Target field: Description
    • JQL Query:
    issuekey in (%{00061})
    

    Note that %{00061} is field code for Ephemeral string 1

    The 2 post-functions should be executed in the same order they are described, i.e., firstly post-function 1) and then post-function 2).

  21. Bharath Kumar reporter

    Can I ask one more question here which is related to the same issue or create a new issue ??

  22. Fidel Castro Armario repo owner

    Please, create a new issue, in order to not make this one too long. If it has some relation with this one, you can mention this issue in the description of the new one.

  23. Log in to comment