How do I add a condition to scriptrunner post-functions that checks if it has already been executed?

Rob Horan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 9, 2020

I need to add a post-function that creates a sub-task during transition.  The key requirement is that this can only be executed once per issue.  Also, because this workflow is highly complex, this post function may appear at different points in the workflow. 

Is there a way to have an indicator or counter or something that the post-function will refer to before executing to ensure it is only executed once per issue?

1 answer

0 votes
Ivan Tovbin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 13, 2020

Hi, 

You pretty much answered your question yourself. You need an indicatior that a sub-task has already been created by said post-function. Now the indicator itself can be pretty much anything you see most fitting for your workflow. These options come to mind:

- The very existence of a subtask, assuming no other subtasks can be present given your workflow logic.

- Some sort of custom field in your parent issue or sub-task, which is populated at sub-task creation and can be used as an indicator.

- Sub-task's summary which answeres a certain pattern. You can then check the existing subtasks' summaries agains this pattern and if one is found then it means that a sub-task has already been created by a post-function.

These are just a few ideas for how you can implement this. Hope this helps.

Rob Horan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 13, 2020

Hi Ivan,

I appreciate your response - unfortunately, I was not clear enough in my post.  

I am not as concerned about the logic as I am the script itself.  I do not know Groovy, or anything comparable.  I can't write the script.  

Trust me, if I could do this with Automation for Jira I would, but ScriptRunner is what my client's got.

Ivan Tovbin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 13, 2020

I see. I was under the impression that you already have a script that creates sub-tasks. Thanks for clarifying.

With that in mind if you can specify what kind of indicator you need I suppose I could help you with the coding part.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events