How to open create issue dialog with callback after issues have been created?

Hi team, I have the following problem with a P2 addon I’m working on.

One page of our addon will allow users to create issues in the context of the our page’s data. My questions are:

  1. How can I open the create issue dialog from our addon page in a way that created issue keys are passed back to the page so I can link the issue keys with our page’s data.
  2. Alternately, how can I pass a parameter to the Create Issue Dialog that can be used in issue created events to link the issues created to our page’s data.

I know a simple way to open the dialog is by clicking on the Create button

 AJS.$(function ($) {
    $("#create_link").click();
});

But this javascript is too simplistic, I don’t know how to send issue created callbacks or parameters for the issue created events I can listen to.

Cheers
Fernando

PD: I’m trying to upload a 74k png image but the editor gets stuck in 100%

2 Likes

My team mate has found the solution to this problem. Using the following javascript, you can open the Create Issue Dialog with a callback. Once all the issues have been created, the callback is called with the created issue data.

WRM.require(["wr!com.atlassian.jira.jira-quick-edit-plugin:quick-create-issue"]);

issueForm = JIRA.Forms.createCreateIssueForm();
issueForm.bind('sessionComplete', function(ev,issues) {
  $.each(issues, function() {
    console.log('You created issue ' + this.issueKey);
  });    
});

issueForm.asDialog().show();

An small catch is that the callback is executed once the dialog has been closed. So if the user closes the page with the dialog open, previously created issues may be lost (for example when the user has checked the Create Another Issue)

Hope it helps

4 Likes