In our Jira Service Desk project - we are using a script (see below) - to detect a "group assignee" change - When this occurs - we clear out the assignee (since the assignee may/many not be in the new group) This all works fine - the issue? The issue is not cleared from the queue of the original assignee - it worked several months back - did not realize it changed - have not upgraded Jira - just several Add-Ons ... no errrors - the script works fine.
I do see where I am getting a warning about this line below:
issueToUpdate.store() //need this to update in database
Use the object's Service or Manager to save values
I'm suspecting that the warning is my issue .. not sure what to change it to.
The full script:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.event.issue.IssueEventBundle
//import com.onresolve.scriptrunner.runner.util.UserMessageUtil
import com.atlassian.jira.issue.MutableIssue;
MutableIssue issueToUpdate = (MutableIssue) event.issue;
//def currentIssue = event.issue;
//def customFieldManager = ComponentAccessor.getCustomFieldManager();
//def groupField = customFieldManager.getCustomFieldObjectByName('Assignee Group');
//def groupFieldValue = issueToUpdate.getCustomFieldValue(groupField);
//UserMessageUtil.success("groupFieldValue>>>" + groupFieldValue)
// UserMessageUtil.success("in ifff>>>" + issueToUpdate.assignee)
def change = event?.getChangeLog()?.getRelated("ChildChangeItem").find {it.field == "Assignee Group"}
if(change)
{
//if (groupFieldValue != null && issueToUpdate.assignee != null) {
// UserMessageUtil.success("in ifff>>>" + issueToUpdate.assignee)
issueToUpdate.setAssignee(null);
issueToUpdate.store() //need this to update in database
} //else {
// UserMessageUtil.success("in else>>>" + issueToUpdate.assignee)
//}
Hi @JDave ,
I think the store() method does not exist or it is already depreciated.
Here's the working code.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue;
def issueManager = ComponentAccessor.getIssueManager();
def issue = (MutableIssue) event.issue;
def change = event?.getChangeLog()?.getRelated("ChildChangeItem").find {it.field == "Assignee Group"}
if(change){
issue.setAssignee(null);
def currentUserObj = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
issueManager.updateIssue(currentUserObj, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.