Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

I need help in Scriptrunner postfunction OPEN

I am still new in Scriptrunner.

I want to create a subtask based on "created subtask" postfunction condition.

What I want to achieve is this:

I have project X --- when an issue in project X move to status "Review" it triggers a postfunction and create issue in project Y and link it to the issue project X.

When an issue is created in project Y it also triggers a postfunction and create a subtask based on the issue type specified.

I want to set a condition in my postfunction to say:
+Only create a subtask if the issue is linked to issue in project X.

Please help I dont know how to do it.
i have tried so many things but it didnt help

1 answer

Hi @Luvo Kautah Ncibane 


Please check this code and modify it if something will be wrong.

import com.atlassian.jira.component.ComponentAccessor

def condition=false

//def inwardLinkedIssues = ComponentAccessor.issueLinkManager.getInwardLinks({
def outwardLinkedIssues = ComponentAccessor.issueLinkManager.getOutwardLinks({
def linkedIssue = it.destinationObject.key

return condition

What you need to know is check what type of link you use. If is outward link use this code as I pasted. If is inward link uncomment inwardLinkedIssues line and comment outwardLinkedIssues.


Let me know if it works




Hi @Sebastian Krzewiński 

Thanks for your response but unfortunatelly it didnt help.

So I even tried this screen-grab.PNG

No luck still.

For some reasons, if i run the code in the  script console it works.

But when  I run it in the postfunction its not working

Which one you run in console and it works?

Can you describe where you put your post function?

Hi @Sebastian Krzewiński 

This is the code:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue

def issue = ComponentAccessor.getIssueManager().getIssueObject("XXXX")
for(IssueLink link: ComponentAccessor.getIssueLinkManager().getIssueLinks(issue.getId())){ if(link.getIssueLinkType().getName().equals("RELATED")) return true } return false;

 it works in the console

I have my post function in the create transition.


In cases like yours I make a "loop transition" and fire it usting fast-track transition.

In your case it will be loop from Todo to Todo. Then move Create subtask post function to loop transition. On Create transition add fast-track transition post function and mark that loop transitionn will be triggered without any condition.

Also you can hide loop transition from all users.

@Sebastian Krzewiński 

Do you perhaps have an example of what you are talking about.

I'm just confused.

Hi @Sebastian Krzewiński 


I only want to create subtasks based on the condtion that i have in the created subtask postfunction

Sorry that my answer wasn't clear enough.

1. Workflow should look like this:


2. On create transition you add fast-track transition post function (without any condition)


3. On loop transition you add your subtask creation function



The reason that I do cases like this was because I saw that on create transition issue isn't be added to database with all needed information. So I must wait and run all needed function on second transition which is triggered from create transition.

From user perspective nothing is happend - issue after creation is in Todo status.




Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira Service Management

Jira Service Management Documentation Opportunities

Hello everyone, Hope everyone is safe! A few months ago we posted an article sharing all the new articles and documentation that we, the AMER Jira Service Management team created. As mentioned ...

192 views 0 5
Join discussion

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