Hello People,
Can anyone help me with the code to clear the system field value during the clone of the issue in jira. we are using script runner add-on.
Example : project = ABC and issue type = Report and field = Component/s
During clone I want to clear the System field Component/s value.
Here I am sharing my code. I used listeners for this.
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 = 10005 //Cloning ID//
String ISSUE_TYPE_ID = 10601 //Report ID//
Set issueComponent = issue.getComponent()
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()
Long textSystemField = issue.getComponent()
issue.setissueComponent(textSystemField, null)
issueManager.updateIssue(loggedInUser, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
Thanks in advance,
Sahish