Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Script Listener with JQL don´t show updated issue

Joerg Strehl
January 15, 2020

Hello,

I need some help with an problem regarding to Listener´s and JQL querys.

So I wrote an Listener which sends an custom mail to the teamleader if the issue is set to priority 1.
In the first step I get the search results from some of our saved filters and then I check if the issue is in one of these filters. Based on the filter I send the mail to the right teamleader.

This works fine until I have an issue with an approval inside the workflow, it seems that the listener is faster than the re-index of the issue in the approval transition. 
When I test the script in the console it works. 

Is there any way to slow down the listener or wait until the re-index is done?

 

Thanks

Joerg

 

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Ronen Erlich
October 10, 2018

I was able to fix it myself (Yay)

instead of behavior I used post function script (my own script):

import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.web.ExecutingHttpRequest
import com.atlassian.jira.issue.UpdateIssueRequest;
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserUtil
import com.onresolve.jira.groovy.user.FormField

//point to the CF navigator Team and get the value
def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def team = customFieldManager.getCustomFieldObject("customfield_14400")
def team_value = issue.getCustomFieldValue(team)

def mIssue = issueManager.getIssueObject(issue.id)

switch (team_value){
case "Data Center Ops":
mIssue.setAssigneeId("x")

break;

case "Data Traffic Engineering & Operations":
mIssue.setAssigneeId("y")

break;

case "Site Reliability Engineering & Storage Engineering":
mIssue.setAssigneeId("z")

break;

case "Sys Ops":
mIssue.setAssigneeId("a")

break;

case "Site Reliability Tools":
mIssue.setAssigneeId("b")

break;

}
TAGS
AUG Leaders

Atlassian Community Events