Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to restrict to copy all fields to subtask using behaviour

varun July 18, 2018

Hello Team,

 

I want a script to restrict copying of All fields to the subtask using behavious ,

I want to exclude some of the fields from copying ,Please help me in this concern,

 

Thanks

Varun

1 answer

0 votes
varun July 18, 2018

When creating an issue of the type "Feature" all the entered information - before clicking "create" - is copied to all sub-tasks.

This is unwanted for the following fields:
• Epic Link
• Original Estimate
• Fix Version
• Description (since the Description is a mandatory field, please just use the summary of the sub-task instead)

Joanna Choules
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 20, 2018

Hi Varun,

I assume you are using the 'Create a sub-task' post-function on a transition? I think you should be able to achieve the desired result by simply nulling out the unwanted fields in the Additional code section, for example:

issue.fixVersions = []

See the ScriptRunner documentation for more details.

Regards,

J

Deleted user July 20, 2018

Thanks for the reply Jake,

It is working fine with fixversions ,

but when I am adding the script for other fields it is not working.

Please let me know how to add other fields.

 

Thanks & Regards,

Varun

Joanna Choules
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 23, 2018

Hi Varun,

What does the script look like for the other fields? Bear in mind that the 'empty' value for a field is not always the empty list []: depending on the field type, it might be null, or the empty string, etc.

J

Deleted user July 23, 2018

Hello Jake,

issue.fixVersions = []
issue.epicLink = []
issue.TimeTracking = []

I am using same as above, I tried with empty and null but in vain,

could you please help in this full code, Please .

 

Thanks in advance,

Varun.

varun July 25, 2018

Hello Jake ,

Could you please help me in this?

Joanna Choules
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 26, 2018

Presumably you are noticing failures in the script since epicLink and TimeTracking are not properties of the issue object.

If you need to clear the Original Estimate field (as you said you needed in your original question) then you can set issue.originalEstimate = 0 (or perhaps null if you don't want to specify explicitly that it should be zero).

Epic Link is technically a custom field, so you would need to do something along the lines of the following:

import com.atlassian.jira.component.ComponentAccessor

def epicLinkCf = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Epic Link")

issue.setCustomFieldValue(epicLinkCf, null)

Suggest an answer

Log in or Sign up to answer