Web Item Provider with recent projects?


similarly as in the provided example:

I wanted to build a web item with my recent projects from specific category.

Is there a simple method to make that work?


2 answers

1 accepted

1 vote

This is not particularly easy so I'll give a full example.

First, add a Raw XML Module to create the web section in the Projects dropdown:

<web-section key='recent-proj-cat-projects' name='ScriptRunner generated web item - active-issues' location='browse_link' weight='70'>
  <label>Recent CAT1 Projects</label>
  <param name='lazy' value='true' />

Modify the label as appropriate.

Now create a new web item provider:

image2016-9-28 12:22:3.png

The code for the provider can be found here: https://gist.github.com/jechlin/cf096c1da6ad5b5e44a8a803bd6fcaa5

And results in:

image2016-9-28 12:24:53.png

1 vote

This should be very similar to the provided examples, except you want to get the project history and filter on the category. Something like:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.UserProjectHistoryManager

def historyManager = ComponentAccessor.getComponent(UserProjectHistoryManager)
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def projectManager = ComponentAccessor.projectManager

if (user) {
    def historyItems = historyManager.getProjectHistoryWithoutPermissionChecks(user)
    historyItems.findAll {
        projectManager.getProjectObj(it.entityId as Long).projectCategory?.name = "CAT1"
    .each {
        // create web item

I didn't bother with error checking to keep the example simple...

Also retrieving the project to get the category may not be fast enough, you'll need to check.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

Meet the AUG leaders of Northern Virginia

@Rachel Wright (Jira Genie), @Billy Poggi (AUG NOVA, DC), and @Dana Jansen (Confluence Queen) are just some of the folks that lead one of the world's most active Atlassian User Group (AUG)....

124 views 4 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you