How to copy parent ticket summary to sub-task summary (by script) ?

Kostas Mackevicius March 12, 2013

I have coded our current JIRA (5.2.6) to create two sub-task on specific workflow transition. Our business users have one request. They want that sub-task should have the same summary as parent ticket + a prefix. Example:

Parent ticket summary: "Good summary"
Sub-task summary: "[Text] Good summary"

So i tried to modify script:

issue.summary = "[Text]" + transientVars["issue"].summary 

but it did not worked.

Can anyone help me with that ?

3 answers

1 accepted

3 votes
Answer accepted
JamieA
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.
March 12, 2013

It's a bit ugly but this is the correct code:

issue.summary = "[Text] " + transientVars["originalissueobject"].summary

Kostas Mackevicius March 13, 2013

Hm, it seems that it does not work. When i set this script then sub-task is not created. If i specify issue.summary = "[Text]" then sub-task with [Text] summary is created.

JamieA
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.
March 13, 2013

I tested this and it did work - try putting your function last in the list of post-functions.

Kostas Mackevicius March 25, 2013

Jamie,

I have several questions. Lets start from begining. With your plugin i create a Sub-task listener. Listener configurations:

-------------------------------------------------------
ID 	Parameters
0 	Create a sub-task.
Subtask will be created with issue type: Descriptions Sub-task
Events: [Subtask Created]
Projects: [MOD]
Edit | Delete | Move down
-------------------------------------------------------
1 	Create a sub-task.
Subtask will be created with issue type: Photography Sub-task
Events: [Subtask Created]
Projects: [MOD]
Edit | Delete | Move up
------------------------------------------------------

Now these listeners are working and creates Sub-task on specifick transition and on "Custom Event".

But when i put issue.summary = "[Text]" then sub-task with [Text] summary is created.

in "Additional issue actions" then listeners do not work. Please see attached image:


Please addvise what i am doing wrong ?

Basically what i need? Example:

On specific transition or workflow in need to create two or more sub-task with summarry: [Description] Parent issue summary.

Looking forward to hearing from you.

JamieA
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.
March 25, 2013

Not really sure what you're trying to do. But when i put issue.summary = "[Text]" then sub-task with [Text] summary is created. is not valid code, I would assume you haven't actually put that, but it's in the screenshot as well.

If the code is invalid (additional script is compiled to code) there will be errors in the log file.

Kostas Mackevicius March 25, 2013

Sorry for the mistake. I am putting:

issue.summary = "[Text] " + transientVars["originalissueobject"].summary

but it seem that then listener do not work. I mean sub-task is not created.

JamieA
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.
March 25, 2013

And the logs say...?

JamieA
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.
March 25, 2013

can't find anything attached, can you paste to gist.github.com or pastebin.com

JamieA
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.
March 25, 2013

transientVars is only available in workflow functions, you should use "event.issue.summary".

JamieA
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.
March 25, 2013

I don't have skype, sorry. Use this:

issue.summary = "[Text] " + event.issue.summary

Kostas Mackevicius March 25, 2013

Now i used

issue.summary = "[Text] " + event.issue.summary["originalissueobject"]
and got an error
java.lang.RuntimeException: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: event for class: Script6
By the way maybe we can skype ? If yes my skype: eziookas
Kostas Mackevicius March 25, 2013

Jamie,

Maybe there is another way to contact you on-real time ?

I have another question about Grovvy Runner plugin.

JamieA
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.
March 25, 2013

Did that work? I'm sure you can understand why I do not do private support consultations for people, unless they are paying.

Kostas Mackevicius March 26, 2013

Jamie,

It did not worked and the same error is shown, I am confused. It is the only thing i need, in order to to finish task from boss. :(

P.S. now i understand you. There is nothing for free in this world :)

Kostas Mackevicius March 27, 2013

Jamie,

Maybe you could advice me how to add

issue.summary = "[Text] " + transientVars["originalissueobject"].summary
as a post-function in the workflow transition ?
Kostas Mackevicius March 27, 2013

Jamie,

I found when it works: issue.summary = '[Description] ' + issue.summary

But another small issue appears. If i executing one again the same transition (on which Script listener is working) additional subtask is created. Ho to avoid that ?

Jamie Echlin March 27, 2013

You need to use the "condition" to check for existing subtasks of the kind that you care about...

! issue.subtaskObjects.any{ it.issueType.name == "Sub-task"}

for example.

> P.S. now i understand you. There is nothing for free in this world :)

Are you kidding me!? You haven't paid for all the expert advice I've been giving you, nor for the plugin myself.

Kostas Mackevicius March 27, 2013

Sorry Jamie,

I did not want to offend your. I respect your advices.

JamieA
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.
March 27, 2013

No problem, no offence taken.

0 votes
Kostas Mackevicius March 12, 2013

I am using Script Runner. I am creating a listener for a specific transition, on which execution JIRa will create two sub-tasks with specific summary. Summary consist of [Prafix]+"Parent ticket summary" Here is a screen shot what i want to do:

0 votes
Jamie Echlin March 12, 2013

What is the context here... what plugin are you using, is this usinga built-in script function?

Suggest an answer

Log in or Sign up to answer