Can somebody give me a working script so i can run using script runner (Groovy)
in order to add all my saved filter for users Distribution automatically subscribe filters on behalf of users ?
thanks
OK, I submit. Here is the script. As someone said before you need to use a group not a username (eg carla).
Please please please close or mark correct your previous questions. If you enter lots of similar questions you are merely making it very difficult for people to help you because they don't know which question to answer.
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.favourites.FavouritesManager
import com.atlassian.jira.issue.search.SearchRequest
import com.atlassian.jira.issue.search.SearchRequestManager
import com.opensymphony.user.UserManager
// Set the filter ID and group to share with here
Long searchRequestId = 10151
String shareWith = "some group"
ComponentManager componentManager = ComponentManager.getInstance()
FavouritesManager favouritesManager = (FavouritesManager) componentManager.getComponentInstanceOfType(FavouritesManager.class)
SearchRequestManager searchRequestManager = componentManager.getSearchRequestManager()
SearchRequest searchRequest = searchRequestManager.getSharedEntity(searchRequestId)
UserManager userManager = UserManager.getInstance()
for (String userId in userManager.getGroup(shareWith).getUsers()) {
favouritesManager.addFavourite(userManager.getUser(userId), searchRequest)
}
Note that the filter needs to be shared, the script above just makes it a favourite. So share with somegroup, then run the script above with somegroup.
If you are having trouble with this perhaps you might be better off with a packaged plugin that doesn't require configuration.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
click on one of the filters in your screenshow, in the url it will show the filter ID.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
from where do I get the the filter ID so I can put in
Long searchRequestId ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Halleluyaaaaaaaaaaa thanks it is working for group )
you saved me from the deep sea )
I am gonna dance LA SAMBA
I need to update all my posts and questions and paste your script
thanks for your answer and your valuable time , I didn t give up I knew the solution is there !
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Jamie is it possible to add several filter ID to the line
Long searchRequestId
this one is for a single filter id Long searchRequestId = 10300
but if i have 10301,10302 ,10303 what can i do
shouu i add them line by line?
Merci
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jamie,
do you have this script updated for Jira 7?
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @JamieA , @Samir Freelance
I tried using the script you provided here, but getting errors. Could you please help?
My Task : I have created a Filter, shared with a Group. Now I want to add this filter as a Favorite Filter to all the members of this Group.
Error1: Unable to resolve class
import com.opensymphony.user.UserManager
I tried using below as well but could not get through.
import
com.atlassian.crowd.embedded.api.User;
It would be really helpful if you have a script for this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.