Script/ database change to "shared with" parametr to share all my filters with all logged users Edited



I'm lookig for a script/ a way to share all jira filters with "all logged users" at once.

I have around 3k filters and need to change permissions for all of them, anyone can help with that?


Best Regards


1 answer

List of User Logins/Logouts from Audit

This groovy script creates an xml output of the audit log filtered by the User Access category, so dates of when users logged in or logged out.


  1. import com.axeda.drm.sdk.device.ModelFinder  
  2. import com.axeda.drm.sdk.Context  
  3. import  
  4. import com.axeda.drm.sdk.device.Model  
  5. import com.axeda.drm.sdk.device.DeviceFinder  
  6. import com.axeda.drm.sdk.device.Device  
  7. import com.axeda.drm.sdk.audit.AuditCategoryList  
  8. import com.axeda.drm.sdk.audit.AuditCategory  
  9. import com.axeda.drm.sdk.audit.AuditEntryFinder  
  10. import com.axeda.drm.sdk.audit.SortType  
  11. import com.axeda.drm.sdk.audit.AuditEntry  
  12. import groovy.xml.MarkupBuilder  
  14. /* 
  15. * AuditEntryList.groovy 
  16. * Creates an xml output of the audit log filtered by the User Access category, so dates of when users logged in or logged out. 
  17. * @param days        -   (REQ):Str number of days to search. 
  18. * @author Sara Streeter <> 
  19. */  
  21. def writer = new StringWriter()  
  22. def xml = new MarkupBuilder(writer)  
  24. try {  
  25.     def ctx = Context.getUserContext()  
  26.     ModelFinder modelFinder = new ModelFinder(ctx, new Identifier(1))  
  27.     Model model = modelFinder.find()  
  28.     DeviceFinder deviceFinder = new DeviceFinder(ctx, new Identifier(1))  
  29.     Device device = deviceFinder.find()  
  30.     AuditCategoryList acl = new AuditCategoryList()  
  31.     acl.add(AuditCategory.USER_ACCESS)  
  32.     long now = System.currentTimeMillis()  
  33.     Date today = new Date(now)  
  34.     def paramdays = parameters.days ? parameters.days: 5  
  35.     long days = 1000 * 60 * 60 * 24 * Integer.valueOf(paramdays)  
  37.     AuditEntryFinder aef = new AuditEntryFinder(ctx)  
  38.     aef.setCategories(acl)  
  39.     aef.setToDate(today)  
  40.     aef.setFromDate(new Date(now - (days)))  
  41.     aef.setSortType(SortType.DATE)  
  42.     aef.sortDescending()  
  43.     List<AuditEntry> audits = aef.findAll()  
  45. // assemble the response  
  46.     xml.Response() {  
  47.         audits.each { AuditEntry audit ->  
  49.             Audit() {  
  50.                 id(audit?.id.value)  
  51.                 user(audit?.user?.username)  
  52.                 date(audit?.date)  
  53.                 category(audit?.category?.bundleKey)  
  54.                 message(audit?.message)  
  55.             }  
  56.         }  
  57.     }  
  59. } catch (def ex) {  
  60.     xml.Response() {  
  61.         Fault {  
  62.             Code('Groovy Exception')  
  63.             Message(ex.getMessage())  
  64.             StringWriter sw = new StringWriter();  
  65.             PrintWriter pw = new PrintWriter(sw);  
  66.             ex.printStackTrace(pw);  
  67.             Detail(sw.toString())  
  68.         }  
  69.     }  
  70. }  
  72. return ['Content-Type': 'text/xml', 'Content': writer.toString()] 

Hi Dinesh,


It's not what I"m looking for I'm afraid, 

I need to change permissions for all my filters, and what to do this with script if it's possible.


Hi Joanna,

      Try this script in script runner plugin and if possible send the screenshot of your requirement where you should change the permissions of all your filters. 


This script does not work at all, please see screen shot, but as I said before it's not what I'm looking for (This groovy script creates an xml output of the audit log filtered by the User Access category, so dates of when users logged in or logged out)



What I need is:


I have over 2k shared filters - shared with some groups, projects, public etc. I

need to change Shared With parametr all of my filters to "Shared with all logged users". All users in my company need to be able to see all filters,

Doing this one by one will take ages, so I'm looking for a script or maybe database change will do the job.

shared filters.png



Script to change permissions

com.atlassian.jira.bc.JiraServiceContextImpl import com.atlassian.jira.bc.filter.SearchRequestService import import com.atlassian.jira.component.ComponentAccessor // import import com.atlassian.jira.sharing.SharePermissionImpl import com.atlassian.jira.sharing.SharedEntity import com.atlassian.jira.sharing.type.ShareType import import def searchRequestService = ComponentAccessor.getComponent(SearchRequestService) def user = ComponentAccessor.jiraAuthenticationContext?.getLoggedInUser() def searchService = ComponentAccessor.getComponent(SearchService) def serviceContext = new JiraServiceContextImpl(user) long filterId = ------ def searchRequestManager = ComponentAccessor.getComponent(SearchRequestManager) def ab = searchRequestManager.getSearchRequestById(filterId) def sharePerm = new SharePermissionImpl(null, ShareType.Name.GLOBAL, null, null) ab.setPermissions(new SharedEntity.SharePermissions([sharePerm] as Set))

Try this and do some changes according to your requirement.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

1,234 views 5 10
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