You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hello all,
I am trying to change the owner of a filter, but I'm not being successful. Any idea why? Any validations that I need to do? Omitted all the imports for clarity.
def decomUser= userManager.getUserByName("vescalante")
def targetUser = userManager.getUserByName("gcheung")
def loggedInUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
// Reassign all filters
SearchRequestService searchRequestService = ComponentAccessor.getComponent(SearchRequestService.class)
def contextImpl = new JiraServiceContextImpl(decomUser)
Collection<SearchRequest> searchRequests = searchRequestService.getOwnedFilters(decomUser)
if(searchRequests.size() > 0) {
searchRequests.each { s ->
s.setOwner(targetUser)
searchRequestService.updateFilter(contextImpl, s)
}
} else {
commentText << "\n\n (/) User *_${decomUser.getName()}_* doesn't own any filters, no reassignment required."
}
log.warn(commentText)
Got it. I had to validate the change.
searchRequestService.validateFilterForChangeOwner(jiraServiceContextImpl, s)
if (jiraServiceContextImpl.errorCollection.hasAnyErrors()){
log.error(iraServiceContextImpl.getErrorCollection())
}
else{
s.setOwner(targetUser)
searchRequestService.updateFilterOwner(jiraServiceContextImpl, loggedInUser, s)
}
Hi Vivian,
Can you please share the full script again?
Thanks in advanced,
Maitrey
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What version of ScriptRunner do you have? I believe you can do this with the built-in scripts Change dashboard or filter ownership. To get to the built-in scripts area you'll need to go to Add-ons > ScriptRunner > Built-in Scripts. Hope this helps!
See below images.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm trying to do this through a groovy script, but thank you. I'm aware this exists. I was able to figure it out!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just to throw out why the built-in script approach didn't work for me: it uses a user lookup for the From user field. If this was a free text box, it'd be better, but because it looks up usernames and only accepts a "valid" user, the built-in script is pretty useless when working with deactivated/deleted accounts.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Vivian Escalante , did you get this to work with private filters? I get it to work if I share it before running the script but when its private I get this:
The filter is not shared with anyone. You cannot change the owner of private filters.
I know this is a old thread but I have been looking around and this was so close to what I need that I give it a go.
br Ole
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.