Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

get Structure View Id?

I am trying to switch the owner of a Structure View. I have received an example ScriptRunner script from ALMWorks to do this. The script requires I know the ID of the View. How/where do I find the Structure View's ID?

1 answer

1 accepted

Hello DPE Team,

David from ALM Works here!

I see that we were able to provide an answer to your question through the ticket you reference.  Sharing it here as well, so others who are looking for a similar solution will be able to find it easily!

The script below has 3 parameters:

Starting with 'oldUserName,' which is the current owner of the view.

'newUserName,' which is the user that will be the owner of the view after the script execution.

And flag 'dryRunMode,' which states that if the value is 'true' - proceed by running the script without changing any states.

We'd first suggest running the script in your staging instance (if there is one) and observe if you get a similar result to this one:

View #42 "asdvfb": admin(admin) -> test
View #8 "my view": admin(admin) -> test
View #9 "progress_view": admin(admin) -> test
View #41 "sorter_test_view": admin(admin) -> test

If you don't get any errors, then run the script again by changing the 'True' value of '*dryRunMode*' to '*false*.'

// change values
def oldUserName = 'test'
def newUserName = 'admin'

def dryRunMode = true

// do not change code below

import com.atlassian.jira.component.ComponentAccessor

def plugin = ComponentAccessor.pluginAccessor.getPlugin('com.almworks.jira.structure')
def JiraUsers = plugin.classLoader.loadClass('com.almworks.jira.structure.api.util.JiraUsers')
def structureComponents = plugin.getModuleDescriptor('structure-components').module
def viewManager = structureComponents.getViewManager()

def result = []

def oldUserKey = ComponentAccessor.getUserManager().getUserByName(oldUserName).getKey()
def newUser = ComponentAccessor.getUserManager().getUserByName(newUserName)

if (oldUserKey == null) {
result << """'Old User' key:'${oldUserKey}' doesn't exist, cannot change the owner of the views"""

if (newUser == null) {
result << """'New User' name:'${newUserName}' doesn't exist, cannot change the owner of the views"""

if (newUser != null && oldUserKey != null) {
viewManager.getViews(null).each { view ->
def user = view.getOwner()
if (user && oldUserKey == user.getKey()) {
result << "View #${} \"${}\": ${view.owner} -> ${}"
if (!dryRunMode) {




Yes the script I received did reassign the owner. The thing I did not like about this solution was that it reassigned the owner for All views the old owner had. I guess it was not a precise as I would have liked. Overall it did what I needed, thanks.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira Software

Presenting the "Best of 2020" Jira Software roundup!

Catch up with Atlassian Product Managers in our 2020 Demo Den round-up! From Advanced Roadmaps to Code in Jira to Next-Gen Workflows, check out the videos below to help up-level your work in the new ...

7,193 views 8 28
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you