Referencing a just-created issue in ScriptRunner post script

Payne
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.
April 23, 2019

I have the following scenario: when an approver approves an issue, I have a post function that creates one or more subtasks and one or more issues of another type. I have a "Single Issue Picker" custom field on the other issue type. As I iterate through, I create a subtask and then the other issue, and I then attempt to place the subtask reference in the Single Issue Picker on the other issue. I get the following error when I attempt to do so:

customfield_13400:Issue: TIS-1028 does not fit filter query: 

customfield_13400 is the Single Issue Picker field, and TI-1028 is the subtask that I just created. I have no JQL on the Single Issue Picker field, so any issue should be a valid value.

I can go in through the UI and set the field as I wish (e.g. I can go into that issue right now and set the field to TIS-1028, and it saves just fine).

I can also update the issue through the script console using the same code that I use in my post function.

I can also hard-code a previously attempted (and failed) subtask reference in the code in the post function.

It appears that the subtask is not fully stored or indexed, thus preventing me from referencing it in this field. I CAN, however, immediately reference it and create a link to/from it.

I've got an open ticket with Atlassian, but I'm not really getting anywhere with it, so I wanted to see if anyone in the Community has encountered a similar situation.

Thanks!

2 answers

0 votes
Payne
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.
April 25, 2019

I tried several different orders on the post functions and also tried manually indexing, all to no avail. I finally threw in the towel and changed from a Single Issue Picker to a text field. Not as tight an integration as I would like, but it works. The field is programmatically set and never edited, so there is no concern about integrity.

-Payne

0 votes
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 24, 2019

What is the order of execution for all your post-functions?
Are you using the built-in create-subtask post function?
It would be helpful to understand how all your pieces come together to come up with some ideas.

A bit of assumption here... but I would guess that if you have the issue key available during the post function... then the new issue has been stored. But perhaps it hasn't been indexed yet.

So maybe adding a manual indexing of the subtask before attempting to set the issue picker value might help.

Suggest an answer

Log in or Sign up to answer