Raw XML Module Built-In Script

All of the built-in scripts produce XML that is similar, but not interchangeable with, XML found in a plugin descriptor. You will notice that, for usability reasons, the forms do not provide all the possible configuration elements available in plugins. For example, the web item script does not give you the option to provide a tooltip for the web item link, a velocity context provider, or an icon URL.

You can work around this limitation by using XML Module Item by following these steps:

  1. Get the required XML from one of the other fragment scripts by filling out the form, then clicking the Preview button.

    Do not click the Save/Update button.

  2. Copy the XML into the Raw XML Module script.

  3. Make modifications as required.

Example

Although the example here is for Jira, similar XML is applicable to Bamboo, Bitbucket and Confluence.

Let’s say we have created a link in the Browse Projects menu, now we wish to menu add a tooltip and icon to the web item. Enter the XML:

               <web-item key='custom-web-item' name='ScriptRunner generated web item - link-to-my-spaces' section='system.header/spaces-menu' weight='70'>
                    <label>My spaces</label>
                    <link linkId='link-to-my-spaces'></link>
                    <tooltip>Show only my spaces</tooltip>
                    <icon height="16" width="16">
                            <link>/images/sr.png</link>
                    </icon>
                </web-item>

Verify the menu item appears as:

The Jira Projects drop-down menu, with new browse options visable.

Using Multiple Items

The other reason for using this built-in script is it allows you to make multiple modifications that belong as a single unit in a single script, which you can enable and disable en bloc.

The XML below allows you to create the following structure, which consists of:

  • a drop-down menu in the top navigation bar

  • a web section activated by that menu item, which has a heading

  • a simple web item

  • a web item provider which creates further items in that section

An example drop-down menu, created with XML.

This is produced by the following XML:

                <web-item key='toppy' name='ScriptRunner generated web item - toppy' section='system.top.navigation.bar' weight='70'>
                  <label>Toppy</label>
                  <link linkId='toppy'></link>
                </web-item>

                <web-section key='top-menu-section' name='ScriptRunner generated web item - top-menu-section' location='toppy' weight='70'>
                  <label>Subby</label>
                  <param name='lazy' value='true' />
                </web-section>

                <web-item key='x-other' name='ScriptRunner generated web item - x-other' section='toppy/top-menu-section' weight='1'>
                  <label>Sub-menu item</label>
                  <link linkId='x-other'>/</link>
                </web-item>

                <web-item-provider key='custom-drop-history-factory' name='ZCreate sub-task for this issue'
                    section='toppy/top-menu-section' class='com/onresolve/jira/groovy/test/fragments/SampleWebItemProvider.groovy' />

XML aficionados will note that the above XML is not technically correct as it does not have a root element, but in this case, a root element will be automatically added for you.

On this page