Web panels can be used to add HTML snippets to parts of a page. For example, they could be used to display additional information on the current wiki page or a Jira issue.

For more information, you can use the web panels Atlassian documentation.

Examples

Deprecated Space Notification

You can inform editors that a certain Confluence space will be deprecated, so they should update a page in another space.

  1. Choose the Show a Web Panel fragment.

  2. Fill out the form:

    web panel

    The weight field is optional, and it only takes positive integers. Lower integers make the panel appear at the top of the section. If the field is blank, appears at the end of the section.

  3. Add the following code to the Provider Class/Script field:

    writer.write("<div style='background-color: yellow; text-align: center'>" +
        "This space is going to be deprecrated. Please move" +
        " all content to the DOCS space</div>")

This is the result of the above web panel, which should only appear in the specified space:

web panel banner
You must write to the provided writer object not just return a string.

Service Desk Portal

You can display a web panel for a specific service desk portal in the servicedesk.portal.header location. . Create a web panel. . Enter this in the Condition section:

+

portal.id == 1

This code works in a portal window as the binding variable portal is available in service desk portal context. But the code throws a groovy missing property exception in the user window because the variable is not available in service desk user window. To avoid this kind of scenario, check the availability of the variable, where applicable:

binding.variables.get("portal") && portal.id == 1
Test the script in different contexts to avoid unexpected errors. If necessary in the script, check availability of the variables to avoid exceptions.

Conditions

Conditions are largely the same as for web item conditions.

Have questions? Visit the Atlassian Community to connect, share, and learn with other Atlassian users and experts, including Adaptavist staff.

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

Want to learn more? Check out courses on Adaptavist Learn, an online platform to onboard and train new users for Atlassian solutions.