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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


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

Atlassian Community Events