Use createIssue & linkIssue together in same SIL

Hello,

I have a request to create an epic template which includes stories and sub-tasks that can be used over and over again. 

Instead of cloning the structure of the template (which would require another plugin) I decided to have an Epic with a specific component that, on creation, launches a script that creates the additional needed stories and sub-tasks and and then links them to the main epic. So far my If statement and createIssue statements work without a problem but I am not sure how to include linkIssue in the same statement if the issue keys haven't yet been created in the DB. 

Code I already have that works: 

//Create new story and sub-task upon creation of new epic and link them to the epic. 


if(component == "Client Upgrade Autocreate"){
    string newTaskKeyFr = createIssue("ABT", "", "Story", "Summary for first story");
    %newTaskKeyFr%.description = "Description for the new story";
    %newTaskKeyFr%.component = "Test";
    linkIssue(parentIssueKey, newTaskkeyFR, "depends on");
    
	string newTaskKeySc = createIssue("ABT", "", "Story", "Summary for second story");
    %newTaskKeySc%.description = "Description for the second new story";
    %newTaskKeySc%.component = "Test";
    
	string newTaskKeySbOne = createIssue("ABT", "", "Sub-task", "Summary for First Sub-task");
    %newTaskKeySbOne%.description = "Description for the first sub-task";
    %newTaskKeySbOne%.component = "Test";
}

Can someone help me out on how to include the linkIssue in the above code. It seems like it should be fairly simple but I can't make sense of it. 

https://confluence.kepler-rominfo.com/display/JJUP14/linkIssue

Thank you, 

 

Avril 

1 answer

1 accepted

Accepted Answer
4 votes

Hi,

 

First thing first, you're using outdated documentation. Use this one instead:

https://confluence.kepler-rominfo.com/display/SIL30/linkIssue

 

Now to the point.

If I understand correctly, you want to launch a post-function on creation of Epic and this function should create two stories and one sub-task, and then link them all to your Epic?

 

Try something like this:

string epicKey = key;
if(component == "Client Upgrade Autocreate"){

    string newTaskKeyFr = createIssue("ABT", "", "Story", "Summary for first story");
    %newTaskKeyFr%.description = "Description for the new story";
    %newTaskKeyFr%.component = "Test";
    linkIssue(epicKey, newTaskkeyFR, "depends on");
    
    string newTaskKeySc = createIssue("ABT", "", "Story", "Summary for second story");
    %newTaskKeySc%.description = "Description for the second new story";
    %newTaskKeySc%.component = "Test";
	linkIssue(epicKey, newTaskkeySc, "depends on");
    
    string newTaskKeySbOne = createIssue("ABT", newTaskKeySc, "Sub-task", "Summary for First Sub-task");
    %newTaskKeySbOne%.description = "Description for the first sub-task";
    %newTaskKeySbOne%.component = "Test";
	linkIssue(epicKey, newTaskKeySbOne, "depends on");
}

 

Remember one important thing: when you will be adding the post-function to the Epic create transition, position it AFTER the "Creates the issue originally" action. This is because the EPIC has to be created first, before it can be linked to.

 

Second thing: above script creates "classic" links. If you want to create Epic Link instead, I think you might have to use JJupin Agile.

Blazej I wouldn't describe it better! Good job.

Hi Blazej,

That fixed the issue and thanks also for the JJupin Agile tip. I hadn't even thought about it as requirements are still coming in. 

Thank you. 

Avril 

Also Ms Bower, when using the linkIssue routine, be sure to use the link name, not the outward or inward issue link value.

See the following question: https://answers.atlassian.com/questions/301971

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Oct 11, 2018 in Marketplace Apps

You + one app + a desert island...

Hi all! My name is Miles and I work on the Marketplace team. We’re looking for better ways to recommend and suggest apps that are truly crowd favorites, so of course we wanted to poll the Community. ...

3,669 views 6 6
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you