How to get a workflow postfunction to show the "Create Issue" screen with pre-filled values?

Roberto Saltini September 17, 2016

By following the instructions given at https://confluence.atlassian.com/jirakb/creating-issues-via-direct-html-links-159474.html I have been able to have a "Create Issue" screen shown as effect of a workflow post-function.

However, the beginning of the link above states that

Please note that the content on this page is not maintained as a supported component of JIRA applications. Consequently Atlassian cannot guarantee to provide any assistance in configuring or implementing it.

We recommend using the JIRA REST API instead of following the steps on this page, as the content is now quite outdated. Please see our JIRA REST API Tutorials for further information.

As far as I am aware, what I want to do cannot be achieved using the REST API.
Is this correct?

If so, what "maintained" method would you suggest me to use in place of that mentioned in the link above?

Thanks

2 answers

1 accepted

0 votes
Answer accepted
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 18, 2016

This seems a little confused as you mention "post functions" a couple of times, but in the wrong context and suggesting that they are doing things that they simply can't.

A post-function is a chunk of code that executes after a transition is committed.  Any transition (including create) will go through things in this order:  Conditions (to check the user can do it), present screen if appropriate, validate entry, then finally the post-functions.  So, post-functions have nothing to do with filling in fields - they happen well after you've finished with the screens and fields.

The REST API does not pre-fill things either.  It does not use the UI, so there is nothing there to be pre-filled.  You can use it for creating issues, and if you do, your code can be written to fill in defaults if you want.  But there's nothing to do in JIRA here, you fill in the defaults in your call.

The doc you have pointed to is about pre-filling values in an html call.  If that is still what you are trying to do, then the method works, but it's still going to be a case of coding in the call to fill values, you're not doing anything in JIRA.



Roberto Saltini September 18, 2016

Hi Nic, my intention is to have a post-function that prompts the screen for creating a new issue and prefills it as well.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 18, 2016

Again, a post-function is part of a transition, and it happens at the end.  It's too late to do anything with the screen. 

Even if it were not, post-functions are not for doing front-end things, they don't have any way to trigger any activity for the user.

If you want to land the user in a "create new issue" screen after a transition (which is probably a bad idea as most users wouldn't expect or want to land there after doing something to another issue), you will need to either hack the core code which currently lands them in a certain place (which differs according to where you're doing it) or write something that can catch "landing on the screen after transition" and jump to the create screen.  The second option is going to need to be some form of javascript that runs in the browser.

 

Roberto Saltini September 18, 2016

Hi Nic. Eventually I got it. I believe that I can get what I want by means of a custom web-item. Thanks.

 

JamieA
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.
September 19, 2016

The way I do this is using a web item which leads to a https://scriptrunner.adaptavist.com/latest/jira/fragments/CreateConstrainedIssue.html

Optionally you can then have the create transition of the new issue action the issue you are creating it "from"...

0 votes
Russell Zera
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 15, 2020

Loooong time delay on this particular ask, but I have accomplished what you are asking to do (in a way) in a bit of a hacky manner... Consider adding a loop transition (a transition from a status back to itself) that has the screen that you want to appear (prompting the user to fill in certain details). Then go to the create transition and add two post-functions... one being the pre-set data you want populating the fields automatically (since this is back-end as @Nic Brough -Adaptavist- is stating), but then have another post-function (LATER in the order of post-functions as it executes in order) that calls the transition you created above. This will then pop the front-end entry screen you desire, but still have the issue end at the status you desire.

NOTES: This is not a super clean way to do it, but I have used these loop transitions for this purpose before and it gets you what you're looking for. Also, you must be certain what transition ID you are calling on this post-function (ESPECIALLY when adding this post-function on a Create transition) as if you accidentally call the CREATE transition (or some OTHER transition that employs the CREATE transition) you can create a loop statement and create a massively impressive number of tickets as fast as your little server's heart can pitter-patter until it ultimately dies or catches fire... Please don't set your server on fire!!!! (Especially don't set the server on fire if you're on Cloud!!!!!) 

Hope this is still relevant and helps!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events