Forums

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

Scriptrunner for Jira Cloud Listener Not Clearing Number and Cascading field Value

Vikrant Yadav
Community Champion
May 22, 2025

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

}

1 answer

1 accepted

2 votes
Answer accepted
Kristian Walker _Adaptavist_
Community Champion
May 22, 2025

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

Vikrant Yadav
Community Champion
May 26, 2025

Hi @Kristian Walker _Adaptavist_ ,

Thanks a lot for sharing the script! 
It's working fine for me. 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events