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
}
Hi Vikrant,
I have an example script here which can be configured as a Script Listener and shows how to use the Rest API to clear field values when they are cloned.
You can modify this example to specify the name of your Number field and cascading select list field, and set it to null to clear the values.
If you need further assistance with this, please raise a support request here so our support team can assist you.
I hope this helps.
Regards,
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.