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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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

1 vote
Stepan Kholodov _ALM Works_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
Nov 19, 2021

Hello @Pavan 

You can try the script below:

package examples.docs.structure

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

@WithPlugin("com.almworks.jira.structure")
@PluginModule
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 support.almworks.com 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
TAGS
AUG Leaders

Atlassian Community Events