JIRA Workflow Toolbox conflicts with ScriptRunner for JIRA plugin

Issue #336 resolved
AndreH created an issue

Setup- JIRA Version 6.4.13 Adaptavist ScriptRunner for JIRA Version: 4.1.3.12 JIRA Workflow Toolbox Version:2.2.11

There is an issue with a Post Function when using the JIRA Workflow Toolbox. It seems to interfere with the Fire a Issue Closed event that can be processed by the listeners.

If I remove my Post Function the Issue Closed event works fine and Script Runner sends a custom email.

However, if I leave the JIRA Workflow Toolbox Post Function in, the Issue Closed event doesn't get registered and no Script Runner email is sent.

This is a snippet of the code for the Post Function:

Value of field Ephemeral string 1 in current issue will be copied to field Issue status (delayed writing) in linked issues or subtasks filtering by:    
Inward issue link types: none 
Outward issue link types: none 
Subtasks won't be written. 
Sibling subtasks fulfilling conditions on issue type, status and project will be written. 
Issue types: Conditional-task.
Statuses: Reopened and Open.
Linked issues or subtasks may belong to any project. 
This feature will be run as user in field Current user.

I will also added an image of the complete Post Functions on Issue Close

Comments (10)

  1. AndreH reporter

    The Post function in the image is Number 4, with the red arrow.

    The Close Issue event is number 10, with the red arrow.

  2. Fidel Castro Armario repo owner

    Hi Andre,

    i have tried to reproduce your problem but in my case it's working correctly. I explain you my configuration:

    • JIRA Workflow Toolbox 2.2.11
    • JIRA 6.4.13
    • Script Runner 4.1.3.12

    My "Close Issue" transition executes the following post-functions:

    Captura de pantalla 2016-06-13 a las 23.33.16.png

    And the listener implemented with Script Runner is:

    Captura de pantalla 2016-06-13 a las 23.35.29.png Captura de pantalla 2016-06-13 a las 23.35.42.png

    Can you please, provide the configuration of the listener you are using?

    Have you checked your log file for error messages?

  3. AndreH reporter

    Hi,

    Yes, I set the Script Runner to debug and I can't find any error in the logs.

    I have also asked the Script Runner Vendor for assistance, however they just stopped responding for assistance. You can see the complete thread on Atlassians Answers - https://answers.atlassian.com/questions/38526798/script-listeners---send-a-custom-email.-problem-sending-email.

    Here is the condition and screen shots of the workflow.

    Condition

    issue.labels.any{it.label=='Transfer'} &&
    (issue.isSubTask() && issue.parentObject.subTaskObjects.every { it.status.name == "Closed"})
    

    Screen1.png Screen2.png

  4. AndreH reporter

    I am also including the Complete Workflow setup. This workflow allows some sub-tasks to be locked from being moved from Open status to any other status, based upon Block and Blocked By links. Unless the previous sub-task is closed, the status cannot be changed from Open. Once the sub-task is Closed, the next sub-task will automatically move from Opened to Assigned.

    Complete WorkFlow.png

    Ready-Issue.png

    Close-Issue.png

  5. Fidel Castro Armario repo owner

    Hi Hughes,

    The problem seems to be caused by the fact that condition is not correctly evaluated by the listener implemented by Script Runner when the post-function is present in the "Close Issue" transition, but I can't find the cause because that post-function is not transitioning issues that are already closed.

    I propose you to replace the listener with "Send an email" post-function. If you decide to do it, please observe the following advices:

    • Move post-function "Set issue status to the linked status or..." after all the custom post-functions, i.e., to 6th position in execution order.
    • Use the following boolean expression in conditional execution parameter:
    %{00080} ~ "Transfer" AND %{00041} != null AND count(siblingSubtasks()) = count(filterByStatus(siblingSubtasks(), "Closed"))
    

    Note that:

    • %{00080} is field code for Labels
    • %{00041} is field code for Parent's issue key

    BTW, I think you should remove post-function 5 from transition "Close Issue". It is not necessary, and is confusing.

  6. AndreH reporter

    Will the Send an Email post function only send an email on the very last Sub-task that is closed?

    The intent was to only send an email if the last sub-task of 17 sub-tasks was closed.

    They don't want an email for every one of the 17 sub-tasks that have closed.

  7. Fidel Castro Armario repo owner

    Yes, the boolean expression at parameter conditional execution is just for that purpose.

    I will also require that the last subtask being closed has a label called "Transfer". I included it since it's also in the listener you had implemented.

  8. AndreH reporter

    Thank you! This Post function works perfectly. You can close this issue.

    Thank you once again for your awesome support .

  9. Log in to comment