Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
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

Insert structure inside a structure using script runner

Hello Team,

Thanks in advance.

Normally , Manually I am able to add structure inside structure.
By following below steps

Automation >> + sign >> insert >> Structure >> structure name >> Done

I want to automate this process using scriptrunner

1 answer

Hello @Pavan 

You can try the script below:


import com.almworks.jira.structure.api.permissions.PermissionLevel
import com.almworks.jira.structure.api.StructureComponents
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.atlassian.jira.component.ComponentAccessor
import com.almworks.jira.structure.api.structure.Structure
import com.almworks.jira.structure.api.forest.action.ForestAction
import com.almworks.jira.structure.api.forest.ForestSpec
import com.almworks.jira.structure.api.item.CoreIdentities
import com.almworks.jira.structure.api.generator.CoreGeneratorParameters

StructureComponents structureComponents

def parentStructureName = "Parent" // name of the structure you want to add this generator to
def innerStructureName = "Inner" // name of the structure to add

def structureManager = structureComponents.getStructureManager()
def forestService = structureComponents.getForestService()
def generatorManager = structureComponents.getGeneratorManager()
def permission = PermissionLevel.valueOf("ADMIN")
def parentStructureId = structureManager.getStructuresByName(parentStructureName, permission)[0].getId()
def innerStructureId = structureManager.getStructuresByName(innerStructureName, permission)[0].getId()

// inserter
def params = ['forestSpec' : ['structureId' : innerStructureId]]
def inserterId = generatorManager.createGenerator("com.almworks.jira.structure:inserter-substructure", params, parentStructureId)
def generatorItem = CoreIdentities.generator(inserterId) // item to add to forest
def forestSource = forestService.getForestSource(ForestSpec.structure(parentStructureId)) //resolving forest source for structure
forestSource.apply(new ForestAction.Add(generatorItem, 0, 0, 0))

I hope this helps. If you need our assistance with anything, please feel free to contact us directly at and we'll get back to you shortly.

Best regards,
Stepan Kholodov
ALM Works

Thanks ! above solution worked for me 
@Stepan Kholodov _ALM Works_ 

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Apps & Integrations

How we use Jira Service Management for our recruitment process! - Part 2

It is never about setting up a process and being done with it. Rather, the focus should always be on optimizing it for the best outcomes. Thus, we didn’t stop at setting up JSM for our recruitment pr...

183 views 0 5
Read article

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