You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
Hi,
I have 3 multi select user field "Approvers" , "Pending Approvers" and "Approved By".
My requirement is - Every time an approver approves, I need to remove the name from Pending Approvers.
This is my code and it gives me error in the last line. I am not sure what did I miss here. can someone help?
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import org.apache.log4j.Category
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
def Category log = Category.getInstance("com.onresolve.jira.groovy.PostFunction")
log.setLevel(org.apache.log4j.Level.DEBUG)
def issueManager = ComponentAccessor.getIssueManager()
//def issue = issueManager.getIssueObject("XXX-215")
def issue=Issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def approvedBy = customFieldManager.getCustomFieldObject("customfield_10760");
def specApprovers = customFieldManager.getCustomFieldObject("customfield_10607");
log.info("approvedBy"+approvedBy)
log.info("specApprovers"+specApprovers)
//List approvedUsers = approvedBy? (List)issue.getCustomFieldValue(approvedBy) : "Field doesn't exist"
List approvedUsers = (List)issue.getCustomFieldValue(approvedBy)
List approvers = (List)issue.getCustomFieldValue(specApprovers)
def pendingApprover=approvers
if (approvedUsers)
pendingApprover.removeAll(approvedUsers)
log.info("Approvers"+approvers)
log.info("Approvedby"+approvedUsers)
log.info("diff"+pendingApprover)
def changeHolder = new DefaultIssueChangeHolder()
//def finalvalue = customFieldManager.getCustomFieldObjects(issue).find {it.name == "Pending Approvers"}
def finalvalue = customFieldManager.getCustomFieldObjectsByName("Pending Approvers")
finalvalue.updateValue(null, issue, new ModifiedValue(finalvalue, pendingApprover),changeHolder)
Error
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.