I would like to mimic the Service Desk Automation function of Auto Approve in a ScriptRunner Script Listener.
I have tried the following:
def result = post("/rest/servicedeskapi/request/${issueKey}/approval/<userid>")
.header('Content-Type', 'application/json')
.body([
fields:[
decision: "approve"
]
])
.asString()
But this returns a 401 error. The user id I am using is set as an Approver.
The documentation I am following is: here
It says that "The approval is assumed to be owned by the user making the call." but I don't understand this - how does an approval have an owner?
After much trial and error, I think I now understand.
Approvals are objects with a set of properties - including whether or not the Approval is required, who the Approvers are etc. You can have multiple Approvals per issue.
Where I had <user id> I should have supplied the ID of the Approval to be approved.
So to do an Auto Approve, you have to do the following:
- set the Approvers field with the ScriptRunner user id (assuming you are running the script as this id)
- get the list of Approvals
- get the id of the Approval that is waiting for approval (and check that it is can be answered)
- provide the Approval, supplying the ID of the Approval
Hello @Nick Hassell ,
I having same problem in here, trying to auto approve issue with automation or scriptrunner when comment added like when approver reply email "Approve" then automation process it,
im oke if the issue just have 1 approvers, it can be done use automation. But i found automation for jira cannot handle this when the issue have more than 1 approvers,
for example i have 1 issue with 4 approvers, email send to the all approvers, but when 1 approvers reply email "approve", approval status in the issue become "Approved" and skip all the rest approvers.
Do you have any code that run auto approve in scriptrunner?
Thankyou,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did anyone get this working withing a ScriptRunner Post Function?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In your follow up comment you mentions the sets you must take with
"get the id of the Approval that is waiting for approval (and check that it is can be answered)"
Could you add a few words on how you get the approval id?
Cheers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If using ScriptRunner, it may be worth looking at:
HAPI - Approving an Issue
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.