Multiple Approvals on Single Transition

Issue #921 resolved
Bharath B created an issue

Hi,

I have a field called Approvers(multiple users), in the workflow we have a transition called Approve.

The condition that I am looking for is all the approvers that are listed in the Approvers(multiple users) field should be able to click on the transition and only when all of them click that approve transition button the issue should go to the next transition. Attached is the screen shot of the workflow.

Comments (11)

  1. Fidel Castro Armario repo owner

    Hi @Bkappala,

    I propose you the following solution:

    1) Create a Multi-User Picker custom field called Approvals. You can add this field to VIEW screen, but don't add it to EDIT or CREATE screen. This field will contain which users have already given their approval.

    2) Create a reflexive transition called "Give Approval" in status "Owner Approval", i.e., a transition with "Owner Approval" as origin and destination status.

    3) Add "Copy a parsed text to a field" post-function to "Give Approval" and "Approve" transitions with the following configuration:

    • Target field: Approvals
    • Parsing mode: basic
    • Text to be parsed: + %{00020}

    where %{00020} is field code for Current user.

    4) Add "Boolean condition with math, date-time or text-string terms" condition to transition "Give Approval" with the following boolean expression:

    %{00020} in %{bbbbb} AND count(toStringList(%{bbbbb})) - count(toStringList(%{aaaaa})) > 1
    

    replacing bbbbb with field code for Approvers, and aaaaa with field code for Approvals.

    5) Add "Boolean condition with math, date-time or text-string terms" condition to transition "Approve" with the following boolean expression:

    %{00020} in %{bbbbb} AND count(toStringList(%{bbbbb})) - count(toStringList(%{aaaaa})) <= 1
    

    replacing bbbbb with field code for Approvers, and aaaaa with field code for Approvals.

  2. Bharath B reporter

    But the Approvers are not predefined list they would be decided when the issue is created and being worked on.

  3. Fidel Castro Armario repo owner

    This solution works with the users selected in field Approvers for each particular issue. The number of approvers can be different for each issue.

  4. Bharath B reporter

    I implemented the solution as suggested but after the first approval, the Give approval transition button disappears

  5. Bharath B reporter

    meaning, lets say we have 2 people in the Approvers field, after the first person hits the Given Approval button then that button dis appears

  6. Fidel Castro Armario repo owner

    Hi @Bkappala,

    That's the expected behavior. If you have 5 approvers, approvals 1 to 4 are done using "Give Approval" transition (transition "Approve" remains hidden), and the last approval (i.e., approval 5) is done using transition "Approve", which now is shown, and transition "Give Approval" will become hidden.

  7. Bharath B reporter

    Works like a charm thank you very much Fidel,

    One small bug that I found in the solution is, let says we have 4 approvals Tom, Dave, Jeff and David.

    Tom, Dave and Jeff finish their approval and only David has to approve in this case lets say Tom, Dave or Jeff visits the ticket they can see the transition button Approve and they are able to hit that button which is taking the issue to the next status, in this case only David should be able to click the Approve button because only his approval is pending.

    Do you think this can be fixed in the current workflow

  8. Fidel Castro Armario repo owner

    Hi @Bkappala,

    You can solve the problem like this:

    1) Use the following condition on transition "Give Approval":

    %{00020} in %{bbbbb} AND %{00020} not in %{aaaaa} AND count(toStringList(%{bbbbb})) - count(toStringList(%{aaaaa})) > 1
    

    2) Use the following condition on transition "Approve":

    %{00020} in %{bbbbb} AND %{00020} not in %{aaaaa} AND count(toStringList(%{bbbbb})) - count(toStringList(%{aaaaa})) <= 1
    

    replacing bbbbb with field code for Approvers, and aaaaa with field code for Approvals.

  9. Bharath B reporter

    Thank you soo much @fcarmario this is a perfect solution for us everything works as needed now just in love with the add-on.

  10. Log in to comment