A web-item is a button or link that will appear at your chosen location.

What happens when the link is clicked is up to you - some examples might be:

Let’s start with a simple example: We would like to add a link to Google on the top navigation bar. Fill out the form as follows:

link to google

Click Update to register the fragment. Go the Dashboard in a new tab, it should look like:

top item
You can understand what the values of the section attribute mean by reading the Atlassian documentation on Web UI modules , or you use the section finder tool.

Clicking the link should take you to Google. Experiment with the Weight field - try setting it to 1. When you refresh the page you should find that your link is now the left-most one.

So far, so easy, but not very useful.

Next we’ll try to add a link to JIRA issues More Actions menu, which will do a Google search on the current issue summary.

Create a new web item or change the values to the following:

page link

You should now be able to see this on the operations bar of any issue:

tools menu link

Note that the URL is processed with velocity before rendering. The variables you can use depend on the context of the Web Item.

If you don’t change the key, the module from the first part of the tutorial will be overwritten.
Unresolved directive in content/common/fragments/WebItem.adoc - include::../jira/src/test/resources/com/onresolve/base/test/rest/jstestutils/IssueApproval.groovy[tags=ex1]

Verify that this works by browsing to: http://<jira-url>/rest/scriptrunner/latest/custom/approve?issueId=12345. It should simply respond with some JSON. If you are doing something with the issue be sure to enter a valid issue ID. The problem we have now is that will probably want to limit approving an issue to just those in a certain group, or with a certain project role. Also, we don’t want to show the menu item if the issue has already been approved. Which brings us to Conditions.


The condition is used to define whether the link should be shown or not, and it can use anything available in its context, plus details of the current user. If the item is on an a view-issue page, you will get the issue. If it is on a project overview section then you may only get the project.

In JIRA, you are provided in the binding with a jiraHelper object, which is an instance of JiraHelper. You can use its methods to retrieve the current project etc. If the issue is available in the context, then that is bound in the script as issue. This means that you can reuse most of the conditions from workflow functions etc. The issue will be available when selecting a section like opsbar-operations, that is, sections that only appear on the View Issue page.

Let’s say that we want to only show the Approve menu item where the the current issue does not already have the approved label…​ we can use:

! ("approved" in issue.labels*.label)

Enter this in as the Condition. It can either be entered inline or written to a file underneath a script root.

You should be able to see now that it doesn’t appear when the issue is not already labelled approved.

Conditions must be written defensively. What is available in the context or jiraHelper map depends on the particular web section, and the page that it’s viewed on.

For instance, a link in the top section (system.top.navigation.bar) will never have access to the current issue. This differs from the Confluence behaviour, where it may or may not have access to additional items.

If you are using a section like operations-top-level, you can assume you will always have the issue context variable defined.

As well as using a script, you can use a concrete class that implements Condition. Why would you want to do this? Because you may wish to extend your own existing Condition, or one provided by the application.

Dialogs (Advanced)

There is some support for showing dialogs, although if you require complex interactions you will need to write some javascript.

To display a dialog when the user clicks a web-item, select the Run code and display a dialog option. The endpoint needs to return HTML for an AUI dialog2. The following REST endpoint code displays a dialog when clicked:

Unresolved directive in content/common/fragments/WebItem.adoc - include::../confluence/src/test/resources/com/onresolve/base/test/rest/jstestutils/ShowDialog.groovy[tags=ex1]

The button with the ID dialog-close-button will be automatically wired to close when clicked if you use a dialog ID of sr-dialog. If you require more complex interactions you should require some javascript and wire the elements, for example:

(function ($) {
    $(function () {
		AJS.dialog2.on("show", function (e) {
			var targetId = e.target.id;
			if (targetId == "my-own-dialog") {
				var someDialog = AJS.dialog2(e.target);
				$(e.target).find("#dialog-close-button").click(function (e) {
				// etc
Removing the dialog from the DOM when the dialog is hidden (for example when pressing the ESC key) is controlled by the data-aui-remove-on-hide attribute. Removing this attribute will hide the dialog rather than remove it when the dialog is hidden. In this case you will need to handle re-showing the dialog in your JavaScript code, the web item trigger will re-render a completely new dialog for you.

You can include your additional dialog with a web resource fragment.

On clicking the link the dialog will display:

show dialog


Sometimes you want to run some code and then redirect to another page, or even the same page after updating it. In that case, just return a redirect. The following example adds a label to the current page/issue and then refreshes it, by redirecting to the same page:

Unresolved directive in content/common/fragments/WebItem.adoc - include::../jira/src/test/resources/com/onresolve/base/test/rest/jstestutils/LabelAndRedirect.groovy[tags=ex1]
Make sure to select Navigate to a link as the intention setting.

Further examples

For how-to questions please ask on Atlassian Answers where there is a very active community. Adaptavist staff are also likely to respond there.

Ask a question about ScriptRunner for JIRA, for for Bitbucket Server, or for Confluence.