import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().getName()
ApplicationUser systemUser = ComponentAccessor.getUserManager().getUserByKey("system");
def issueManager = ComponentAccessor.getIssueManager()
CustomField approversCF = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(11718) // Approvers custom field
def approversCFValue = issue.getCustomFieldValue(approversCF)
def approvers = []
approversCFValue.each { appUser ->
approvers.add(appUser.getName())
}
log.info "Approvers : " +approvers
if(!approvers.isEmpty()){
if(currentUser in approvers){
approvers.remove(currentUser)
}
issue.setCustomFieldValue(approversCF, approvers)
}
issueManager.updateIssue(systemUser, issue, EventDispatchOption.ISSUE_UPDATED, false)
log.info "after removing approvers : " +approvers
def currentUser = ComponentAccessur.getJiraAuthenticationContext().getLoggedInUser().getName()
So you're declaring the currentUser to be String (username). And later on trying to work with it as if it was an ApplicationUser object in
if (currentUser in approvers)
approvers.remove(currentUser)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you @Radek Dostál for your response.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.