Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

I want to clear the field value during the clone of the issue

Hi All,

Any one can help me with code to clear the field value during the clone of the issue in jira.we are using script runner add-on help me with solution.


Example : project = xyz and issue type = story and field = Testing .


During clone I want to clear the testing custom field it can be done using script runner add-on.



Kedar P




2 answers

0 votes
Hana Kučerová Community Leader Dec 05, 2020

Hi @kedar ,

just to be clear - you are using "Script Post-Function [ScriptRunner]: Clones an issue, and links" post function to clone the issue? If so, how exactly does your configuration of this post function look like? There's "Fields to copy" configuration, where you can select, which fields should be copied to the cloned issue - so maybe you can just skip this field? Which type has your custom field? Thank you for the clarification.

Hi Hana,

Thanks for your help.


Field type was free text field and during the clone of issue that text field value should I can do this

Hana Kučerová Community Leader Dec 06, 2020

Hi @kedar ,

would you please provide me information, how exactly do you perform the clone operation?



We have a project called accounting and in that project we have custom field called accounting which was text field type custom during the clone of issue in that project with bug issue type we need to clear that field value during the clone operation so after clone that cloned issue  should not show any value in that accounting field . 

Hi Hana,

We have project called accounting and field called accounting text type field.what we doing was when I perform the clone operation in the accounting project with bug issue type card.accounting field should not have any value it should show as null in cloned issue.


Can you help with this.



Kedar P

Hana Kučerová Community Leader Dec 07, 2020

Hi @kedar ,

thank you.

Probably you will need to create Custom listener for the event Issue Created and your accounting project. In the script you will have to check, whether the issue was created as a clone (issue is linked with it's source using specific link and has specific summary)

If so, set the custom field to empty string and store the issue.

Can you help me with the code how to write using project = accounting and issue type = bug and custom field = accounting (text type)

During clone operation have to clear the field value of accounting.



Kedar p 

Hana any help on this.

Hi @kedar ,

please try to add this as a script listener for your project and IssueLinkCreatedEvent event.

xxxxx needs to by replaced by your Cloners link type id, yyyyy by your text custom field id and zzzzz by your story issue type id

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.user.ApplicationUser

String ISSUE_TYPE_ID = "zzzzz"

IssueLink issueLink = event.getIssueLink()
if (issueLink.getIssueLinkType().getId() != ISSUE_LINK_TYPE_ID) {
MutableIssue issue = issueLink.getSourceObject()
if (issue.getIssueType().getId() != ISSUE_TYPE_ID) {
IssueManager issueManager = ComponentAccessor.getIssueManager()
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
ApplicationUser loggedInUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
CustomField textCustomField = customFieldManager.getCustomFieldObject(TEXT_CUSTOM_FIELD_ID)
issue.setCustomFieldValue(textCustomField, null)
issueManager.updateIssue(loggedInUser, issue, EventDispatchOption.DO_NOT_DISPATCH, false)


Hi Hana,

Thanks for the code.

I have a question regarding this 


1. Please let me know that which script listener functionality I should select from the snapshot.

2.After creating the script listener which post function we need to apply on the create transition.

3.what was the issue link type ID.

Please review the snaps.



Kedar IMG_20201212_013210.jpgIMG_20201212_010107.jpg

Hana Kučerová Community Leader Dec 12, 2020

Hi @kedar ,

it is Custom listener (first item in the second screenshot).

In the listener's configuration you will need to select your project and also IssueLinkCreatedEvent event.

It should work like this - if issue link is created and it is Cloners link, get the cloned issue, check, if it is a story and if so, clear the text custom field value.

It is little bit tricky, because the only possible way I was able to find how to determine, if the issue was cloned, is the two issues are linked by Cloners link. The clone functionality has two steps - first of all the cloned issue is created and then the issues are linked. That's why IssueLinkCreatedEvent is used instead of IssueCreated.

There is no need to use any additional post function etc.

Any help on this request 

Suggest an answer

Log in or Sign up to answer

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you