How to clear assignee using script runner custom listener Edited

I need to clear assignee field in JIRA using script runner custom listener. 

I wrote the below script to listen to field "Assigned Workgroup" when it is updated then I want to clear Assignee field

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import java.sql.Timestamp
import groovy.time.TimeCategory
import java.time.*


def issue = event.getIssue()
def issueKey = issue.getKey()
def issueInputParameters = issue.getAssignee()
def date1 = new Timestamp(new Date().getTime())
def date2 = new Timestamp(new Date().getTime() - 5000)


def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def change = changeHistoryManager.getChangeItemsForField(issue, "Assigned Workgroup")
String KISH = change.findAll{it.created < date1 && it.created > date2}

if (KISH == '[]'){
return null
}else{
issue.setAssignee(null)  - This line throws error saying "check if declared type is right and if the method exists"
}

1 answer

1 accepted

0 vote
Alexey Matveev Community Champion Dec 11, 2017

Try to run the script. I think it is just a static compilation error. If you run it, then it should work

Yes it did, the error was misleading. Thank you

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

561 views 1 18
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you