Copy a field value from parent to stories and subtasks

Issue #406 resolved
Bharath Kumar created an issue

I want to copy a field, lets say field A from the epic onto Stories linked to the epic and also the sub-tasks inside the stories.

Example is like I have a field called "PID : 1a1a" on the epic page , I want to see the same value "PID : 1a1a" in the stories linked to the epic and also the same value inside the sub-tasks that are under the stories

Comments (7)

  1. Fidel Castro Armario repo owner

    It can be done using a post-function. There are two approaches:

    1. Post-function is executed in the workflow of the Epic issues (i.e., copy from Epic to Story and its subtask).
    2. Post-function is executed in the workflow of the Story and its subtask (i.e., read the field from Epic into Story and its subtask). In this approach we can insert the post-funcion in Create Issue transition, so that the field is set whenever a Story or a Subtask is created.

    Which approach do you prefer?

  2. Bharath Kumar reporter

    If you dont mind could you please help me with both the approaches, ideally what we wanted was when ever we have the field A in epic updated then the same value should be updated in the stories and sub-task but I know that we can only do that through a transition.

    Please help me with both the approaches I will figure out which one would be the best for us because we want to try both the approaches and then see what will come close to the requirement.

  3. Fidel Castro Armario repo owner

    #Approach 1: Post-function in Epic's workflow #

    Add the following 2 post-functions to a transition in parent issue:

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

    Captura de pantalla 2016-09-10 a las 0.03.17.png

    Text to be parsed is:

    toString(filterByIssueType(linkedIssues("is Epic of"), "Story") UNION subtasks(filterByIssueType(linkedIssues("is Epic of"), "Story")))
    

    I'm considering that by Story you mean all issues with certain Epic and with Story issue type. In case you want to consider all issue types with a certain Epic, i.e., don't limit issue types, you should use the following text to be parsed:

    toString(linkedIssues("is Epic of") UNION subtasks(linkedIssues("is Epic of")))
    

    2) Post-function "Write field on issues returned by JQL query" with the following configuration: Captura de pantalla 2016-09-10 a las 0.12.36.png JQL query is:

    issuekey in (%{00061})
    

    Once configured, your transition in Epic's workflow will look like this: Captura de pantalla 2016-09-10 a las 0.14.10.png

  4. Fidel Castro Armario repo owner

    #Approach 2: Post-function in Story and their subtasks #

    You should use post-function "Copy a parsed text to a field" in Stories and their substasks workflows with the following configuration:

    • Target field: A
    • Parsing mode: advanced
    • Text to be parsed (in the workflow of Story issues):
    first(fieldValue(%{nnnnn}, linkedIssues("has Epic")))
    
    • Text to be parsed (in the workflow of Story's subtasks):
    first(fieldValue(%{nnnnn}, linkedIssues("has Epic", %{00041})))
    

    Note that:

    • nnnnn should be replaced with field code of A custom field. This code depends of each particular JIRA instance.
    • %{00041} is field code of Parent's issue key.
  5. Bharath Kumar reporter

    I tried both of them and both of the solutions work perfectly well, you are really a great man thanks for the help I will keep you posted if any problem comes up thanks once again.

  6. Log in to comment