Using the Jira Announcement Banner on Screens Where Live Fields is not Supported

Live Fields only supports the create, view, and edit screens. This Knowledgebase article shows how to run JavaScript using the Jira Announcement Banner.

Basic Configuration

This example script will check to see if the current user is a Jira admin. If the current user is not an admin, then it will hide an element from the DOM.

  1. Create a basic webhook using Webhooks configuration documentation. Use the script below.

    // webhook accepts the first value passed in the webhook url WebhookPayload httpRequestPayload = getWebhookPayload(); string httpMethod = httpRequestPayload.httpMethod; string httpPayload = httpRequestPayload.payload; WebhookParam[] httpQueryParams = httpRequestPayload.queryParams; // string firstQueryParamName = httpQueryParams[0].name; string userName = httpQueryParams[0].values[0]; /* scripting section -- you can create any script you wish here */ // the current script checks to see if the current user is an admin // enter any group the current user should belong to appendToWebhookResponse(userInGroup("jira-administrators", userName)); return true, 200;


  2. Use the following JavaScript to query the webhook using AJAX. Use this documentation to discover the query selector of the element you wish to hide. Paste the query selector below where it reads, "query selector goes here".

    <script type='text/javascript'> var currentUser = AJS.$("meta[name='ajs-remote-user']").attr("content"); // console.log(currentUser); AJS.$.ajax({ url: "http://localhost:8080/rest/keplerrominfo/refapp/latest/webhooks/isAuthorized/run?username=" + currentUser }).then(function(isAuthorized) { // console.log(isAuthorized + " ---------------------- " + new Date()); if (isAuthorized == "false") { AJS.$("query selector goes here").hide(); } }); </script>


  3. Paste the JavaScript into the Jira Announcement Banner by navigating to admin (the cog) → System, then click on the “Announcement banner” link. Paste the above code into the “Announcement” field.


Please note that using this method to hide elements from users is not intended as a security feature. In most cases, the user will still be able to see the hidden element for a split-second as the page is rendered.

Filter by label

There are no items with the selected labels at this time.