Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,298,502
Community Members
 
Community Events
165
Community Groups

Clear fields via listeners

Hi all,

I am trying to use listeners to clear the field value for some fields as soon as the issue gets updated.

The fields which I want to have cleared are in another tab. Nevertheless, I have listet them as below. 

// get custom fields
def customFields = get("/rest/api/2/field")
.asObject(List)
.body
.findAll { (it as Map).custom } as List<Map>

def toUpdate1CfId = customFields.find { it.name == 'Compliance Risk' }10257
def toUpdate2CfId = customFields.find { it.name == 'GDPR Risk' }10258
def toUpdate3CfId = customFields.find { it.name == 'Business Risk' }10259
def toUpdate4CfId = customFields.find { it.name == 'technical Risk' }10432
def toUpdate5CfId = customFields.find { it.name == 'Compliance Prio' }10260
def toUpdate6CfId = customFields.find { it.name == 'GDPR Prio' }10261
def toUpdate7CfId = customFields.find { it.name == 'Business Value' }10262

def tomorrowStr = (new Date() + 1).format("yyyy-MM-dd'T'HH:mm:ssZ", TimeZone.getTimeZone("UTC")) // date format in iso8601
def resp = put("/rest/api/2/issue/${issue.key}")
.header('Content-Type', 'application/json')
.body([
fields: [
(toUpdate1CfId): 'NULL',
(toUpdate2CfId): 'NULL',
(toUpdate3CfId): 'NUKK',
(toUpdate4CfId): 'NULL',
(toUpdate5CfId): 'NULL',
(toUpdate6CfId): 'NULL',
(toUpdate7CfId): 'NULL'
]
])
.asString()
assert resp.status == 204

Also, defined the trigger as seen in the screenshot.

Screenshot 2022-05-05 at 11.19.15.png

Do you have any experiences on this? Any advice how to make this work?

Thanks a lot!

Best,

Xheneta from Munich

 

1 answer

Hi @Xheneta G_ Hyseni  I am not sure how script runner listner works in JIRA cloud. But an alternate solution is that you can use Project Automation to clear field value when issue is updating. 

Similar post :- https://community.atlassian.com/t5/Jira-Service-Management/How-to-use-automation-to-clear-date-value-on-change-of-status/qaq-p/1525817

 

Thanks

V.Y

Hi @Vikrant Yadav ,

That does not really work in my case since I got a a few fields to update unfortunately. I already tried it with automations first. 

Thanks anyway!

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you