[Jython][JIRA 5.1] how to make reindex() sequence?

Hi all :)

is here anyone who has problems with reindex in jira 5.1?

In version 4 ewerything works fine, but now i can't find resolution for my problem (scenario):

Issue in "Awainting for acceptance" status, and there is transition "Accept" to status "Closed". In JSS I try create subTask (code attached below). subTask was created succesfully, and i can see new subTask in Issue Navigator.

After this (in the same transition in "post functions") issue resolution is updated to "Close", and when i view Issue i see correct status and resolution. But in Issue Navigator the issue is still in "Awaiting for acceptance" status. Now i have workaround with loop transition which do nothing but (i think) reindex issue.

Where i have error in the code?

from com.atlassian.jira import ComponentManager
 
from com.atlassian.jira.util import ImportUtils
import datetime
 
from com.atlassian.jira.issue import IssueManager
 
cfm = ComponentManager.getInstance().getCustomFieldManager()
 
def getField(f, i=issue):
    try:
        return i.getCustomFieldValue(cfm.getCustomFieldObject(f))
    except:
        return None
 
def setField(f, v=None, i=issue):
    try:
        i.setCustomFieldValue(cfm.getCustomFieldObject(f), v)
    except:
        raise Exception(v)
 
def getFieldDate(f, i=issue):
    return datetime.datetime.strptime(str(getField(f)), "%Y-%m-%d %H:%M:%S")
 
userUtil=ComponentManager.getInstance().getUserUtil()
subTaskManager = ComponentManager.getInstance().getSubTaskManager()
 
begintime = getFieldDate('customfield_10116')
endtime = getFieldDate('customfield_10117')
 
# if counter is set
if getField('customfield_11495'):
# get all users in participants (and create sub-tasks)
    users = getField('customfield_10270')
    for user in users:
        issueFactory = ComponentManager.getInstance().getIssueFactory()
        issueObject = issueFactory.getIssue()
        issueObject.setProject(issue.getProject())
        issueObject.setIssueTypeId("96")
        issueObject.setSecurityLevelId(10221)
        issueManager = ComponentManager.getInstance().getIssueManager()
        issueObject.setReporter(user)
        issueObject.setSummary("%s (%s %s) [%d]" % (user.getName(),  begintime.strftime("%Y-%m-%d"), endtime.strftime("%Y-%m-%d"), len(users)))
        issueObject.setAssignee(user)
        subTask = issueManager.createIssueObject(user, issueObject)
        subTaskManager.createSubTaskIssueLink(issue, subTask, userUtil.getUserObject(str(user)))
        ImportUtils.setIndexIssues(True)
        ComponentManager.getInstance().getIndexManager().reIndex(issue)
        ComponentManager.getInstance().getIndexManager().reIndex(subTask)ImportUtils.setIndexIssues(False)

1 answer

1 accepted

This widget could not be displayed.

hm. i have some solution and it's work for me:

delete lines

ImportUtils.setIndexIssues(True)

and

ImportUtils.setIndexIssues(False)

and in workflow/postfunctions the pythjon script is moved down after "re-index"

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

97 views 1 0
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you