Hello Atlassian community and I am trying to make a Listener so that when editing the assigne field there is another field called support group with value L1 if the user to whom the request is assigned is not in that group it should be deleted, however I have not been able to share my code
Your code seems OK, considering the fact that you set up a token and use for your connection.
For the rest, let me try to give you some snippet which may lead you to the right point.
def response = new JsonSlurper().parseText(connection.inputStream.text)
def members = response?.members?.values?.collect { it.accountId } ?: []
def assignee = issue.getAssignee()
if (assignee != null && !members.contains(assignee.getKey())) {
// Assignee is not in the support group; delete the custom field value
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customField = customFieldManager.getCustomFieldObject(customFieldId)
issue.setCustomFieldValue(customField, null)
def issueManager = ComponentAccessor.getIssueManager()
issueManager.updateIssue(event.getUser(), issue, EventDispatchOption.DO_NOT_DISPATCH, false)
log.info("Custom field 'Support Group' value cleared because assignee is not in the group.")
}
I hope it helps
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.