Uploaded image for project: 'SR for Jira - Development'
  1. SR for Jira - Development
  2. SRJIRA-2926

Create Constrained Issue Dialog Doesn't Work

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Done
    • High
    • Resolution: Fixed
    • 5.4.12
    • 5.5.5
    • None
    • None
    • 3.4

    Description

      Update 21 Sept 2018

      This is caused by https://jira.atlassian.com/browse/JRASERVER-67719, which is currently in progress. 

      If this is fixed by Atlassian and released shortly we won't fix it on our side, as we will need to remove the fix when Atlassian fix the JIRA bug. If they don't we will make efforts to work around the bug on our side.

      In JIRA 7.10.0 and above, the Create Constrained Issue Dialog box does not pop up. Instead, it opens in a new tab or the original tab and any Behaviors that are set on it no longer work.

      This was tested in JIRA 7.10.0 and JIRA 7.9.2 with the same version of ScriptRunner (5.4.12) and it does not work in versions after 7.10.0, but it worked fine in 7.9.2. 

      I tested the example from the documentation with a clean instance of JIRA and successfully reproduced the error. 

      The screenshots included show the example from the docs working on version 7.9.2 and not working on version 7.10.0

      Workaround

      • Navigate to Constrained create issue dialog and fill the fields as usual, but instead of add click Preview
      • Copy the resulted XML
      • Navigate to Raw XML Module
      • Paste the XML
      • Edit the above XML

      Replace styleClass with constrained-issue-item and in the link add in the end of the link the following lines &decorator=dialog&inline=true

      For example for the following XML when you preview Constrained create issue dialog

      <web-item key='constrained-issue-key' name='ScriptRunner generated web item - custom-web-item-key' section='operations-top-level' weight='100'>
        <label>Create Issue</label>
        <styleClass>sr-create-bound-issue</styleClass>
        <link linkId='constrained-issue-key'>/jira/secure/CreateIssue.jspa?pid=10000&amp;issuetype=10104</link>
      </web-item>
      

      The edited XML that you will save as a Raw XML Module should be

      <web-item key='constrained-issue-key' name='ScriptRunner generated web item - custom-web-item-key' section='operations-top-level' weight='100'>
        <label>Create Issue</label>
        <styleClass>constrained-issue-item</styleClass>
        <link linkId='constrained-issue-key'>/jira/secure/CreateIssue.jspa?pid=10001&amp;issuetype=10000&amp;decorator=dialog&amp;inline=true</link>
      </web-item>
      
      • Click Update
      • Under your script roots create the following file constrained-item.js with the following code
        (function ($) {
        
            function addTriggers() {
        
                //this should be the web item linkId
                var itemKey = $("#constrained-issue-key");
                itemKey.off("click").on("click", function (e) {
        
                    function getURLParameter(url, name) {
                        return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(url) || [, ""])[1].replace(/\+/g, '%20')) || null;
                    }
        
                    var $link = $(this);
                    e.preventDefault();
        
                    var form = JIRA.Forms.createCreateIssueForm({
                        issueType: getURLParameter($link.attr("href"), "issuetype"),
                        pid: getURLParameter($link.attr("href"), "pid")
                    });
        
                    var dialog = form.asDialog({id: "create-constrained-issue-dialog"});
        
                    var onFormEvent = function ($link) {
                        return function (formEvent) {
        
                            var $formElement = formEvent.target.$element;
                            $formElement.find("form").prepend("<div style='display: none' id='sr_behaviour_info' " +
                                "data-sr_behaviour_id='" + $link.attr("id") + "' " +
                                "data-sr_context_issue_id='" + JIRA.Issue.getIssueId() + "' " +
                                ">");
                        }
                    };
        
                    form.bind("contentRefreshed", onFormEvent($link));
                    form.bind("sessionComplete", function () {location.reload();});
        
                    dialog.bind('Dialog.hide', function () {AJS.$(document).unbind("QuickCreateIssue.validationError");});
                    dialog.show();
                });
            }
        
            JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (event, $context, reason) {
        
                if (window.location.href.indexOf("RapidBoard.jspa?") > -1) {
                    $("#ghx-detail-issue").livequery(function () {
                       addTriggers();
                    });
                }
        
                if (reason === JIRA.CONTENT_ADDED_REASON.pageLoad || reason === JIRA.CONTENT_ADDED_REASON.panelRefreshed ) {
                    addTriggers();
                }
            });
        
        })(AJS.$);
        
      • Select Install web resource  with the following values
        Note: Any note will be fine
        Context(s): jira.general
        Key: Any key will be fine
        Resources: the path to the constrained-item.js file you just created under your script roots

                So eventually will look something like
              

      • Click Update

      Now everything should work as expected. I know that the workaround may be a bit lengthy but, since the bug is in the JIRA and the Atlassian - JRASERVER-67719 - we do not have any alternatives but wait for them to fix it. 

      Attachments

        Activity

          People

            rholban Roland Holban [X] (Inactive)
            ccreswell Carmen Creswell [X] (Inactive)
            Votes:
            9 Vote for this issue
            Watchers:
            21 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: