Hello all,
I have a send custom email on post function transition.
I would like to check the error queue after the email is sent either by the same post function or script listener to see if the email has been sent with no errors.
It takes approx. 12 mins after for the email to go to the error queue if the email is unsuccessful, so i need to post-pone my script to check the email queue 12 mins after post function.
I've managed to compile the below Code to run in fast track transition so if the condition is true then it transitions its status:
import java.util.concurrent.TimeUnit
TimeUnit.MINUTES.sleep(13) // Takes 13 mins after retry to go into error queue when unsuccessful
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.UpdateIssueRequest
import com.atlassian.mail.queue.MailQueue
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
Issue issue = issue
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
def mailQueue = ComponentAccessor.getComponent(MailQueue)
String key = issue.getKey()
String errorQueue = mailQueue.getErrorQueue()
if (errorQueue.contains(key))
return true
else false
But if i do this, the transition screen wont proceed and will be stuck in loading for 13 mins.
What its suppose to do is, basically checks the error email queue when the email is sent 13 mins after and then identify if the issue key is in the error queue then it should transition to a "failed reply" status.
Is there any way around this or can anyone offer a better solution to check for the error queue after the email has been sent.
Many thanks,
Pon