Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How can we force an approval notification?

I'm using the following code to run in a scriptrunner mail handler:

 

//CREATE the query for approvals
ApprovalQuery query = approvalService.newQueryBuilder().issue(issue.id).build();
PagedResponse<Approval> approvals = approvalService.getApprovals(user, query)
log.warn("Incoming mail handler | approvals.getResults() = ${approvals.getResults()}")

//get the last approval- the pending one
Approval unansweredapproval = approvals.results[-1]
log.warn("Incoming mail handler | approvalService.canAnswerApproval(user, unansweredapproval) = ${approvalService.canAnswerApproval(user, unansweredapproval)}")

//Execute the approval
String decision = "approve"
log.warn("Incoming mail handler | decision = ${decision}")
ApprovalDecisionType decisionType = decision.contains("approve") ? ApprovalDecisionType.APPROVED : ApprovalDecisionType.REJECTED
log.warn("Incoming mail handler | decisionType = ${decisionType}")
def answer = approvalService.answerApproval(user, unansweredapproval, decisionType)

 

For some reason, when this is executed via mail handler or listener, it breaks future notifications.  Ideally, I'd like it not to break notifications but for now, how can I force send a notification?

 

If I run this directly in the scriptrunner console, it works fine and everything is ok.  

1 answer

Hi @JordanJ

I understand that you want to send notifications to the Approvers to ensure that they approve the tickets. Is this correct?

If so, you will need to get the Approval details by using the REST Endpoint and filter it to get the Approver's email addresses. An example of this REST Endpoint code is available in the Adaptavist Library.

Next, you can, for example, use the Escalation Service to invoke the REST Endpoint to get the email addresses of the Approvers and send the email notifications to the Approvers. An example code for this is also available in the Adaptavist Library.

I hope this helps to answer your question. :)

Thank you and Kind Regards,

Ram

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.13.13
TAGS
Community showcase
Published in Jira Service Management

JSM Jira Automation: How to Send SLA Breached Notifications

Hi Everyone, In   this tutorial,  we will show you how you can monitor an SLA, and send notifications before or after the SLA has been breached.   SLA Threshold Trigger The SLA t...

660 views 5 12
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you