Unable to get field value from in transition linked epic

Issue #413 resolved
Sahil Gulhane created an issue

Problem description-

Structure- We have Epics which are created at the beginning of the month and contain the Budgets of 7 different types of categories. For example - Activity 1, budget = A

When creating tasks the user has to choose the type of cost [Activity 1]. After selecting this type he will enter the costs = x, y , z etc. Total costs in ticket = x+y+...+n = B

the condition we want- If B > A, >> False, error message- You have exceeded your budget

If B <= A, Allow ticket creation

Post function, if , Ticket created, then, Update A = A - B (Which means the budget is reduced for next ticket)

I tried using simple boolean validation of the create ticket transition. The problem i faced is that i cannot parse or get the value of the Available budget (A), form the epic that is assigned to the ticket during that current transition.

Comments (12)

  1. Fidel Castro Armario repo owner

    Hi Sahil,

    Which is the typical and maximum number of tasks you have for a given Epic? I want to know if I can propose a solution where remaining budget for a Epic can be recalculated each time a task is created.

  2. Sahil Gulhane reporter

    Hello Fidel,

    The typical number of tickets will be 20-25, Yes we would need to calculate the remaining budget every time a new ticket is created.

  3. Fidel Castro Armario repo owner

    I'm assuming that there is a field called Original Budget which contains the original budget of the Epic, which is not modified by trasks, and another field called Remaining Budget which is modified each time a task is created.

    The solution step by step consist of:

    1) Add "Boolean validator with math, date-time or text-string terms" to Create Issue transition in task's workflow with the following boolean expression:

    first(fieldValue({nnnnn}, linkedIssues("has Epic"))) >= sum([{xxxxx}, {yyyyy}, {zzzzz}])
    

    replacing:

    • nnnnn with field code for Remaining Budget
    • xxxxx, yyyyy and zzzzz with the field codes of fields X, Y and Z. Obviously, you can add as many fields as you need.

    2) Add "Write field on linked issues or subtasks" post-function to Create Issue transition in task's workflow with the following configuration:

    • Select a source type: math or date-time
    • Source value:
    ^{nnnnn} - sum([{xxxxx}, {yyyyy}, {zzzzz}])
    

    doing the same replacements as in the validator.

    • Target field: Remaining Budget
    • Filtering by issue link type: check only "has Epic"
    • Write also subtasks fulfilling condition on issue type, status and project: UNCHECKED
    • Write also sibling subtasks fulfilling condition on issue type, status and project: UNCHECKED
    • Filtering linked issues or subtasks by issue type: all UNCHECKED
    • Filtering linked issues or subtasks by status: all UNCHECKED
    • Linked issues or subtasks belong to: any project
    • Filtering by field values: leave it EMPTY
    • Write linked issues and subtasks recursively: UNCHECKED
    • Conditional execution: leave it EMPTY

    IMPORTANT: add this post-function AFTER "Creates the issue originally" post-function.

    3) Optionally you can add a global reflexive transition in Epic's workflow called "Recalculate Remaining Budget" that will refresh the value of this field based on the actual costs of its tasks.

    A global transition is available from any status, and a reflexive transition has the same origin and destination status. The following screenshot shows how to create these kind of transitions.

    Add "Mathematical and date-time expression calculator" post-function to "Recalculate Remaining Budget" transition in Epic's workflow with the following configuration:

    • Target field: Remaining Budget
    • Formula:
    {ooooo} - sum(mathOnIssueList(linkedIssues("is Epic of"), sum([^{xxxxx}, ^{yyyyy}, ^{zzzzz}])))
    

    replacing:

    • ooooo with field code for Original Budget
    • xxxxx, yyyyy and zzzzz with the field codes of fields X, Y and Z. Obviously, you can add as many fields as you need.
  4. Sahil Gulhane reporter

    Hello,

    Yes the field Structure is exactly as you described, we have 2 fields The error i am getting in the first step you mentioned is that-

    1. When the sum of amounts x, y, z .... is > Remaining Budget, Validation is failed and error message is shown (Correct behavior)
    2. When the amounts of x, y and z are reduced and validation is true, I still see the error message and cannot create ticket. (Incorrect behavior)

    I cant seem to solve this issue. I also want to clarify that, This validation is added to the "create issue" transition. The epic is not already linked to the ticket, do we have to define anywhere which field should the condition be parsing as different epics will have different values but same field ID. (Sorry if this question is stupid, i do not have a tech background)

  5. Fidel Castro Armario repo owner

    There was an error in my the boolean expression of the first step, and in the formula of the second step. I have just edited my previous post.

    Please, add field Epic to Create screen of task's. This way the link to the Epic will be available when the validator is executed.

  6. Sahil Gulhane reporter

    Hello, the field "Epic" is already present on the crate issue screen for Tasks. I am still getting the error.

  7. Sahil Gulhane reporter

    Yes i have corrected the validator, but still the same issue. This was the validator-

    first(fieldValue({10300}, linkedIssues("has Epic"))) >= sum([{10246}, {10230}])

  8. Fidel Castro Armario repo owner

    Hi Sahil,

    There is a bug in the plugin in relation with Epic issue links set in transition screens. I have fixed it in version 2.2.20_beta_3. If you install this version the validator in "Create Issue" transition will work as expected.

    I have also edited the formula in parameter Source value in step 2 in order to make it simpler.

  9. Log in to comment