Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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


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.

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.

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
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

394 views 3 17
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you