All of the built-in scripts produce XML that is similar, but not interchangeable with, the 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. As an example, the web-item built-in script does not give you the option to provide a tooltip for the web-item link, or a velocity context provider, or an icon URL.

You can work around this limitation by using this built-in script. First of all, get the required XML from one of the other fragment built-in scripts by filling out the form, then clicking the Preview button. Do not click the Save/Update button.

You can then copy the emitted XML into the Raw XML module built-in script, and make any modifications as required.

For example, you can use the following XML to create a link to your spaces using a tooltip and icon:

<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:

raw xml example 1

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 a web section in the Administration dropdown menu. In the new web section, two web items are added. In this example, they are Contact Admin Team and Contact Support Team.

raw xml example 2

This is produced by the following XML:

<web-section key='admin-web-section' name='ScriptRunner generated web item - admin-web-section' location='system.admin.global' weight='200'>
     <label>Web section</label>
     <param name='lazy' value='true' />
 </web-section>
 <web-item key='contact-admin-team' name='ScriptRunner generated web item - contact-admin-team' section='system.admin.global/admin-web-section' weight='50'>
     <label>Contact admin team</label>
     <link linkId='contact-admin-team'>adaptavist.com</link>
 </web-item>
 <web-item key='contact-support-team' name='ScriptRunner generated web item - contact-support-team' section='system.admin.global/admin-web-section' weight='100'>
     <label>Contact support team</label>
     <link linkId='contact-support-team'>adaptavist.com</link>
    </web-item>
XML aficianados 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.

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.