Script Runner's Create Subtask post-funciton is adding the epic from parent!?

JohnC February 5, 2015

Hi @Jamie Echlin [Adaptavist],  

Using your script runner plugin, I have a transition that simply creates a couple of sub-tasks and it works perfectly. However, if the parent issue is in an Epic the sub-tasks are created and added to the Epic. As you know a sub-task cannot be assigned to an Epic under normal usage.  I have no script or post-funtion to do this and have even tried adding a postfunction on the sub-tasks create transition to clear the "Epic-Link" field however that does not work.  Do you have any ideas on how I can prevent this from happening?  

Thanks in advance

2 answers

1 accepted

2 votes
Answer accepted
Alejo Villarrubia [Adaptavist]
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.
February 6, 2015

Hi John,

You will need to provide the following code to the "Additional issue actions" field in the configuration of the Create a Sub-task post-function. 

checkLink = {link -> false};

By doing that, new sub-tasks of the stories that belong to an Epic will not be listed under the "Issues in Epic" section of that Epic.

You can take a look at the following documentation to get more information about what checkLink is doing:

https://jamieechlin.atlassian.net/wiki/display/GRV/Built-In+Scripts#Built-InScripts-Controlofcloninglinks

JohnC February 6, 2015

Thanks! works as expected now.

Gautam August 6, 2015

It doesnt work for me. The subtask continue to show up under Epic and its creating a mess. Any help?

Alejo Villarrubia [Adaptavist]
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.
August 6, 2015

Gautam, can you give some info about the versions of Jira and ScriptRunner your instance is running?

Gautam August 6, 2015

Thanks for responding. My JIRA version is v6.2 and Scriptrunner instance is 2.1.17

Jonny Carter
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.
August 25, 2016

Just an update for those finding their way here: see my answer at https://answers.atlassian.com/questions/40003636. You can set/clear the Epic Link just like any other custom field in the Additional Actions, along with controlling link copying behavior separately.

checkLink = {link -> false};
def epic = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Epic Link'}
issue.setCustomFieldValue(epic, null)
Anand Sridharan July 27, 2017

That didn't work for me. I am using JIRA 6.2, Script runner - 3.0.16. Neither the subtasks are created with the "Epic Link" set to null , nor the epic stops listing the subtasks under the story. 

Jonny Carter
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.
July 31, 2017

Ah, yeah, I should have paid closer attention to the version numbers. All bets are off with older unsupported versions of ScriptRunner & JIRA. A lot of those post-functions were rewritten to make use of deeper JIRA validation services to prevent this sort of misbehaviour.

0 votes
Graciela Persch Severo August 16, 2019

Hi all,

I have the exact same issue and when I try to add "checkLink = {link -> false};" on my script runner code it is giving an error on the "-" saying " Expecting '}', found '-' "

My current little code just validates one field and create sub-tasks if that specific field is with the correct value.

 

Any ideas? Version:5.3.26

Derek Sheeman June 24, 2020

I just crashed into the same problem :(

Hi, @Graciela Persch Severo  @Derek Sheeman 

Same here the syntax didn't work for me, but the following worked

checkLink = {link -> false}
def epicLink = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Epic Link'}
issue.setCustomFieldValue(epicLink, null)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events