Forums

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

How to clear custom fields when cloning an issue

Katie_R
Contributor
June 8, 2022

Our customer has asked if there is a way to clear two custom fields when an issue is cloned. We are using Jira Data Center 8.20.5 and have ScriptRunner. We did find a script in the community that works for this, but it uses a specific issue type so it won't work for us. This would be for cloning any issue type. The two fields are a radio button and a database picker that goes into a specific table and then allows you to select one or more sprints from the table. Here is the script we are starting with that we got from another community post but we can't seem to figure out how to correct it to what we want:

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)

Any assistance is appreciated. Thank you!

1 answer

0 votes
Brant Schroeder
Community Champion
October 13, 2017

A board can have any type of project or issue that is in JIRA.  You just need to adjust the Boards filter or when creating the board configuring the filter to include the specific projects and issues.  The board will also need to have the proper columns so you can migrate issues to different statuses.  Once you have the issues on the board you can create the sprint and add issues from multiple projects.

Here is an article on configuring a board.  The righ hand menu on the article has information about filters, creating a board, etc. - https://confluence.atlassian.com/agile066/jira-agile-user-s-guide/configuring-a-board

hitesh.khetani
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 9, 2020

Is it possible for a board to have multiple projects within a Next-Gen Project?

Like # people like this
Ahmet Kilic - T2T
Community Champion
July 14, 2021

Hey Hitesch,

cause the team-managed projects formely next-gen project has no filter adjustment. you are not able to do this. 

Team-managed project concept is actually that it gives you ability to manage spesific tasks which takes 3-4 months. It is also not so useful to manage multiple projects. 

I hope, it helps.

Best,

Ahmet Kilic

Certified Atlassian TAM and SPC

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events