You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.
View groupJoin the community to find out what other Atlassian users are discussing, debating and creating.
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 value.how it can be done using script runner add-on.
Thanks,
Kedar P
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 cleared.how I can do this
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.
Hana,
We have a project called accounting and in that project we have custom field called accounting which was text field type custom field.so 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 .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
Thansk,
Kedar P
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
Thanks,
Kedar p
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.
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.issue.link.IssueLink
import com.atlassian.jira.user.ApplicationUser
Long ISSUE_LINK_TYPE_ID = xxxxx
Long TEXT_CUSTOM_FIELD_ID = yyyyy
String ISSUE_TYPE_ID = "zzzzz"
IssueLink issueLink = event.getIssueLink()
if (issueLink.getIssueLinkType().getId() != ISSUE_LINK_TYPE_ID) {
return
}
MutableIssue issue = issueLink.getSourceObject()
if (issue.getIssueType().getId() != ISSUE_TYPE_ID) {
return
}
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
Thanks,
Kedar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.