Hi Experts,
I am trying to create a listener which clear the issue field for the cloned issue. Able to clear the assignee field but script is not clearing Number field, cascading field. Kindly suggest. Or what would be correct scable approach for clearing a field when cloning an issue.
import groovy.json.JsonOutput
import com.adaptavist.hapi.cloud.jira.issues.Issues
def eventIssue = Issues.getByKey(issue.key as String)
logger.info("Clearing fields for issue: ${eventIssue.key}")
// Clear the assignee using REST API PUT call
def body = [
fields: [
assignee: null
]
]
def result = put("/rest/api/3/issue/${eventIssue.key}")
.header("Content-Type", "application/json")
.body(JsonOutput.toJson(body))
.asString()
// Clear custom fields using HAPI's update method with unambiguous nulls
eventIssue.update {
setCustomFieldValue('Field 3', null as int) // Number field cleared
//setCustomFieldValue('Field 4', (Long[]) null) // Number field cleared
//setCustomFieldValue('Countries', null as Object[]) // Cascading select cleared
}