Problem in Post-Function Script

tomkx February 3, 2014

I have writte a post-functiion script which I am running with ScriptRunner. It clones an issue to a different project.

The script is triggered by the status change from "open" to "in progress". So far it works fine, the only strange problem is that in the list overview the status of the origin issue is displayed (even after browser refresh) with the status "open" while in the detail view the new status "in progress"is correctly displayed. The script as such works fine.

Anybody an idea what the reason could be?

Cheers,

Thomas

3 answers

1 accepted

0 votes
Answer accepted
tomkx February 9, 2014

Thanks Henning. Moving the posftfunction past the reindex solved the problem.

0 votes
tomkx February 5, 2014
Thanks for your explanation. I am creating a new issue in a different project For that I am only invoking getters on the origin issue.
The only place where the origin issue might be changed is the where I create the link which is linking the origin and the copied issue.

The code fragment is shown below:
IssueLinkService.AddIssueLinkValidationResult linkValidationResult = issueLinkService.validateAddIssueLinks(currentUserObj, issue, linkType.id, Direction.OUT, targetIssueList, false);
    if (linkValidationResult.isValid()) {
        issueLinkService.addIssueLinks(currentUserObj,linkValidationResult);
    }

Could that create that problem?
Btw, I cannot reproduce the problem on my local version 6.1.5. Unfornutately, I cannot upgrade the installlation where I have to run the script.

0 votes
Henning Tietgens
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 4, 2014

Your index has the wrong value for your origin issue. You have to make sure that you are using the provided issue object if you're making any changes to the origin issue. If you get a new issue object in the postfunction it's the old issue without the transition information. If you update the issue using this object you have an index problem.

tomkx February 5, 2014

Thanks for your explanation.

I am creating a new issue in a different project. For that I only invoke getterrs on the origin issue.

The only place where the origin issue might be changed is where I create the link which linking the origin and the new issue.

IssueLinkService.AddIssueLinkValidationResult linkValidationResult = issueLinkService.validateAddIssueLinks(currentUserObj, issue, linkType.id, Direction.OUT, targetIssueList, false);
    if (linkValidationResult.isValid()) {
        issueLinkService.addIssueLinks(currentUserObj,linkValidationResult);
    }

Could create that problem?

Btw, I cannot reproduce that problem on my local Jira 6.1.5. Unfortunately, I cannot upgrade the target Jira to 6.1.5 right now.

Any further idea?

Henning Tietgens
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 5, 2014

Yes, that could be the problem. In the JIRA source of version 6.0.7 the addIssueLinks() method calls issueManager.createIssueLink() only with the ID of the issue, which is then used to reindex a new issue object (which doesn't know about the changes).

Try to place your post function after the reindexing takes place could solve the problem.

Suggest an answer

Log in or Sign up to answer