I would like to use this script (https://jamieechlin.atlassian.net/wiki/display/GRV/Built-In+Scripts#Built-InScripts-Createasub-task) to create a subtask and copy fields from the parent to the subtask, eventually modifying some (like the subtask summary to be "Prefix - parent summary" for instance).
Is this possible or it only accepts literal values? If possible how do I reference the parent and subtasks issues in the postfunction?
Thanks in advance!
Hi there,
it's possible to do the thing that you want.
If you want the summary of child task to be "Prefix - {parent summary}" in your postfunction setting you have to add the following in Additional issue actions field
issue.summary = 'Prefix ' + issue.getSummary()
If you have custom fields in your parent issue and you want to use the values in subtask you have first to create the custom field object. You can add the following in Additional issue actions field
def cf_1 = customFieldManager.getCustomFieldObjectByName('customfield_name') val_1 = 'Test ' + issue.getCustomFieldValue(cf_1) issue.setSummary(val_1)
Be careful to have the subtask issue type in your custom field configuration.
Hope that helps
Cheers
Thanks, this is what I needed.
Only one question: issue is a reference to the parent , to the subtask or to both (since it's in both sides of the assignment) ..???
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
issue is a reference to the new issue, in this case the subtask.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Bartosz,
As Jamie said, issue refers to the sub-task. To reference the parent object you can go to it directly using transientVars["issue"].<field>
Here is an example:
issue.assignee == transientVars["issue"].assignee; issue.description == null; issue.setSummary("Unit Test - " + transientVars["issue"].key);
Cheers,
Brannon
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bartosz,
I haven't tried (that I recall) but it should work as you have above with the change noted:
cfParent = customFieldManager.getCustomFieldObjectByName('CUSTOM_FIELD_ID') parentMyFieldValue = transientVars["issue"].getCustomFieldValue(cfParent)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm trying to do something similar with the clone + link builtin script. I simply want to change the security level of the newly created issue.
But its tough to get a handle on that new issue.
log.debug("DBG: issue key is " + transientVars["sourceIssue"].key)
is causing a null pointer exception. Is there some other way to access the new, auto-created, cloned and linked issue?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jamie,
I believe there is a bug in the code that creates subtasks. Looking at your source, you have a parameter called "SKIP_EPIC_LINKS". But it looks like that does not get passed in the call from CreateSubTask to AbstractCloneIssue.
Hence my auto-created subtasks have Epic Link values. The Jira GUI explicitly stops the user from editing that field (only on subtasks) because it knows it should not be there!
I have created a ticket: https://jamieechlin.atlassian.net/i#browse/GRV-409
-Johnny
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jamie, Thank you for the quick response!
Could you please clarify "everything"? Or can we see the source code so we can determine for ourselves?
-Johnny
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Jamie,
Re: inheriting, how can we control that? And to what granularity? Or is this a matter of explicitly undoing all the copying
In particular, we noticed that the subtasks are inheriting the Description field from the parent issue. We would like the subtasks _not_ to inherit anything from the parent.
Thank you,
Johnny
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It inherits everything - you can unset what you don't need in the "additional code" section.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Brannon.
It works.
One more question. Is this a way to get customfields value from parent? I have some problems with that and I don't know why yet.
For instance:
issue.setSummary(
"Unit Test - "
+ transientVars[
"issue"
].customfield-10912);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It doesn't work for me because it doesn't get values from parent issue.
I have tried to get some informations from parent but I received 'null' when I have called getParentObject() due it was called from a sub-task in post-function during creation.
parent = issue.getParentObject() cfParent = customFieldManager.getCustomFieldObjectByName('CUSTOM_FIELD_ID') parentMyFieldValue = parent.getCustomFieldValue(cfParent) issue.setDescription(parentMyFieldValue)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
All fields are by default copied from the parent issue (where the issue type association is valid). To set custom fields to custom values you need to do more or less as Kostas says.
There's no restriction to text fields.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jamie,
I am seeing errors regarding the copy of all parent fields. We have JIRA Agile and the Epic Link field is copied from a story to a subtask. The Epic Link field is not valid for subtasks and is throwing errors.
Is there any way to fix this problem?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you create a ticket including the stack trace?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Seems to be the same as this issue below: https://jamieechlin.atlassian.net/browse/GRV-409- looking at that now.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes agreed, same issue.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.