How to block 'With unresolved tickets' button from Assets search page ?


Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.

Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Important supportability disclaimer!

Customizations like these are not supported by Atlassian (Atlassian Support Offerings) and should be used at the Jira Admins' own discretion and risk.

You may find support from fellow users in the Community or through the services provided by Atlassian Solution Partners. This article only offers some best practices should you really need to implement something like this.

On version upgrades

Also keep in mind there's no "contract" for the HTML elements in any of Atlassian products and they may change on any release without any public notice — unlike Jira's public Java API, REST API or AJS itself. This means you should include tests on your upgrade checklist to make sure the customizations you may have applied through custom Javascript still work in the new version you're upgrading to.

Troubleshooting

A crucial step of troubleshooting is to disable or remove any JavaScript customization (even temporarily) and observe if the reported issue still persists. If you have implemented any such customizations, be advised Atlassian Support may ask you to remove or disable them to isolate any possible interference during troubleshooting — these customizations may interfere with Jira in ways it was not designed to handle and result in malfunctions on unrelated features or interfaces.

Summary

This knowledge base article describes a scenario where Jira/Insight admin wants to disable or block the 'With unresolved tickets' option from AssetsSearch for objects page.



Environment

JSM before 5.11.x with Assets (Previously known as Insight Asset Management)

Diagnosis

There was a known bug where AQL search using connectedTickets() might lead to a slow loading time based on the data size. In page AssetsSearch for objects there is a button in left "With unresolved tickets" which also invokes AQL object having connectedTickets(resolution = Unresolved)

JSDSERVER-11050 - Getting issue details... STATUS

This bug is permanently fixed in JSM v5.11.x and above. If you're running JSM on a lower version and cannot upgrade immediately the workaround could be to disable this button "With unresolved tickets"  to avoid users inadvertently running into this bug. Also if we can disable any other AQL calls for connectedTickets AQL function that would help further to avoid Performance issues.

(lightbulb) Our recommendation/preference would always be to upgrade JSM to the fixed version instead of using custom JavaScript workaround.

Solution

  1. This javascript should help hide the button "With unresolved tickets". This example has some best practices shared on How to customize Jira with JavaScript and CSS.

    <!-- Hiding the "With unresolved tickets" button on Assets  -->
    <script>
    let count = 0;
    let interval = setInterval(function () {
      count++;
      if (count > 10) {
        console.info("[Custom Announcement Banner] Exhausted attempts to locate and remove Assets button.");
        clearInterval(interval);
      }
      else {
        AJS.toInit(function() {
          if (document.URL.indexOf("/secure/insight/search") >= 0) {
            try {
              document.querySelector('button[title="With unresolved tickets"]').style.display = "none";
              console.info("[Custom Announcement Banner] Assets button removed.");
              clearInterval(interval);
            } catch (error) {}
          }
        });
      }
    }, 500);
    </script>


     
  2. One of the users was also able to block objects having connectedTickets() at the Apache level. Below is the code block used in Apache.

## START - Blocking assets connectedtickets search "With unresolved tickets" ## 
    <IfModule mod_rewrite.c>
        RewriteCond %{REQUEST_METHOD} (GET|POST|PUT|DELETE)
        RewriteCond %{REQUEST_URI} ^/jira/rest/insight-am/1/search$
        RewriteCond %{QUERY_STRING} .*object\+having\+connectedTickets.*$
        RewriteRule .* - [F,L]
    </IfModule>
## END - Blocking assets connectedtickets search "With unresolved tickets" ##

Last modified on Sep 26, 2023

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.