We have an approval process, with just one approval level. I'm using ScriptRunner to try and capture who approved the issue so I can pass it onto a new issue that gets created after the approval process.
Everything that I've found online or using AI does not give me the results that I'm looking for.
Here's the script that I'm using to test this functionality. In this example, someone named Tim approved Key-123.
import com.atlassian.jira.issue.Issue import com.atlassian.jira.component.ComponentAccessor import com.atlassian.servicedesk.api.approval.ApprovalService import com.atlassian.servicedesk.api.approval.ApprovalDecisionType import com.onresolve.scriptrunner.runner.customisers.WithPlugin @WithPlugin("com.atlassian.servicedesk") //Get LOGS issue Issue logissue = Issues.getByKey("Key-123") def approvals = logissue.getApprovals() //def approvalService = ComponentAccessor.getOSGiComponentInstanceOfType(ApprovalService) //def approvalUser = approvalService.getApprovals(logissue) //def approvalUser = approvals[0].getApprovers().getProperties().getClass().methods.collect { it.name } def approvalUser = approvals[0].getApprovalCondition().getMetaClass().methods.collect { it.name} //.getClass().methods.collect { it.name } return approvalUser
I've Got It
def approvals = logsIssue.getApprovals()
approvals.each { approval ->
approval.getApprovers().each{ approver ->
if (approver.getApproverDecision()) {
jiraLog.info("Status: " + approver.getApproverDecision().get())
jiraLog.info("User: " + approver.approverUser.getName())
}
}
jiraLog.info("Completed Date: ${approval.getDecision().get().completedDate}")
jiraLog.info("Decision: ${approval.getDecision().get().decision}")
jiraLog.info("Approval ID: ${approval.id}, Status: ${approval.statusId}, Approver: ${approval.id}")
}
@Jeramy -
Can you provide more information on your ask?
1) Have you try to use Automation for Jira (This is a part of your DC version now), where you can create automation rule to obtain issue related data based on issue events. This means that you may not need to use ScriptRunner for Jira for this action.
2) On the new issue, how do you create the new issue that you want to pass in your other issue's approver user info? Via ScriptRunner? You can also use automation rule setup to create the new issue where you can pass in the approver user info to the new issue.
Please advise, so we can assist further.
Best, Joseph
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I work with @Jeramy
We have all of this working, apart from extracting the ApplicationUser object of the user who approved the first issue.
We can get the Decision and date:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.