Forums

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

Clear fields while cloning issue

tifonas-katrina March 26, 2018

Hi,

I am a new Jira Admin. I have a self-hosted system on version 7.2.3 and script runner on version 5.3.1.

Previous admin have created an automation according to which they can clone bugs to HotFixes upon request. The HF created inherits all fields from the parent issue(bug).

They have now come up with a request, demanding that the Original Estimate field should be purged to the child issue(HF). I have tried:

def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Original Estimate'}
issue.setCustomFieldValue(cf, null)

 but it doesn't function.

 

Any ideas about this?  

1 answer

0 votes
Alexey Matveev
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 26, 2018

Try to change your script to this one

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption

def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'MyCustomFieldType'}
issue.setCustomFieldValue(cf, 'my value')
ComponentAccessor.getIssueManager().updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED, false)
tifonas-katrina March 27, 2018

Thanks a lot for your reply but it doesn't function.

I think the problem is with issue.setCustomField valueUntitled.png

Alexey Matveev
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, 2018

You put your script in the Condition part, but you need to put your script into the Additional Issue Actions part

tifonas-katrina March 28, 2018

Even though I put script to the "additional conditions", the clone is not created at all.

Alexey Matveev
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 28, 2018

What is in the Codition field right now?

tifonas-katrina March 28, 2018

isUserMemberOfRole('Project Owner') && cfValues['HotFix Required']?.value == 'Approved'

 

I believe this happens cause for build-in fields there is a box where you can select what to inherit to child issue.

All those lines we are trying to make work are usefull only for custom fields.

 

I believe this is the key that was missing all those days. What do you think?

Suggest an answer

Log in or Sign up to answer