We have a few workflows where there are multiple approval steps in succession, these are normally different people but in some cases the approver for stage 1 is the same as the approver for stage 2. We are looking for a way to automate the approval if the approvers match, so the approver only has to click approve once and both stages will be approved..
In theory this could be achieved via post function, where it pulls the user that approve the request and compares this to the user select field used for the approvers of stage 2. Then if the approver of stage 1 is present automatically transition the approval of stage 2.
I've tried to drill into the approval field using groovy Misc Workflow extension specifically but so far I have not been able to retrieve the user who has approved the current approval of the ticket.
Has anyone else achieved this or something similar?
Can you share the script you have right now? Also, can you provide details on the approvers field as well?
Thanks
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.servicedesk.api.approval.ApprovalService
def issue = ComponentAccessor.getIssueManager().getIssueObject("BLKS-65673") // For console testing
def approvalService = ComponentAccessor.getOSGiComponentInstanceOfType(ApprovalService)
def approval = issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObjectsByName('Approvals').first()).getApprovals()
hi Fabian currently just the above, I've seen examples of pulling pending approvers , https://community.atlassian.com/t5/Adaptavist-questions/Scriptrunner-How-to-list-approvers/qaq-p/793699,
But not one that pulls the user that actually did the approval which is what I am after in this case.
The approvers field is a system field that should be present in all Jira service management instances, rather than a bespoke custom field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is what I would do. When the issue is approved through the transition you would copy the assignee to a new user picker customfield called "first approved by".
Then you can jira automation or scripts to check that when the issue is transitioned, if the "first approved by" matches the second approver field, then transition the ticket to the next stage.
Cheers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi Fabian,
I've considered a similar approach however in my case the assignee of the tickets does not change with the approver.
So I would need to return with a groovy post function the user who triggered said transition aka the approver. Then map that onto a field or such with a conditional auto transition.
def Teamleaders = ACRFunctions.GetEmployeeTeamleaderJirauser(issue)
def user = currentUser.name
Teamleaders.contains("user")
then if the contains returns true to auto transition which seems to work as I need.
Next bit to figure out would be how to auto approve the next transition which i'll look into other community questions for.
Thanks for taking a look,
Mark
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.