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

Moving Insight objects via Groovy fails

as we have to move objects in various steps we want to automate this with groovy. I've seen similar requests in the forum but no valid answers.

The move with the following script works but the details / attributes are lost.
The objectTypes have the same parent and the source has one additional attribute that will be discarded.

Anybody with an idea?

import helper.InsightManager

def im = new InsightManager()

def asset = im.getObjectBean("PROD-208936")

def moveMap = new MoveObjectMapping().create()
def fromAtts = im.objectTypeAttributeFacade.findObjectTypeAttributeBeans(asset.objectTypeId)
def toAtts = im.objectTypeAttributeFacade.findObjectTypeAttributeBeans(20),MoveAttributeMapping.create(fromAtts.find{id=59},toAtts.find{id=59})) // Key,MoveAttributeMapping.create(fromAtts.find{id=259},toAtts.find{id=259})) // Artikelnummer,MoveAttributeMapping.create(fromAtts.find{id=60},toAtts.find{id=60})) // Artikelname,MoveAttributeMapping.create(fromAtts.find{id=61},toAtts.find{id=61})) // Created,MoveAttributeMapping.create(fromAtts.find{id=4522},toAtts.find{id=4522})) // Hersteller,MoveAttributeMapping.create(fromAtts.find{id=62},toAtts.find{id=62})) // Updated,MoveAttributeMapping.create(fromAtts.find{id=4839},toAtts.find{id=4839})) // Gewicht,MoveAttributeMapping.create(fromAtts.find{id=403})) // Kategorie

def mObject = new MoveObjectBean()

mObject.setIql("Key = " + asset.objectKey)


2 answers

2 accepted

Sorry, the stupiest mistake. In the find closure there were assigments (id=59) instead of comparison (

0 votes
Answer accepted

I have implemented a similar move (between two child object types with the same parent) and didn't need to use the "storeObjectBean" method.

So I wonder if that's what tripping your script. 

The moveObjects method kicks off an asynchronous process so in your case, perhaps the storeObjectBean method is attempting to save the old version of the object while the move is still being processed.

I had a similar problem when I was trying to populate a new attribute (date/time of the move on the target object after the move) before the move was complete.

I solved it by waiting for the move to complete before resuming any other part of my script.

Something like this:

def moveProgress = objectFacade.moveObjects(mObject)
Integer curWait = 0
Integer maxWaitMillis = 10000

log.debug "Waiting for move to finish: $curWait ($moveProgress.status)"
while (moveProgress.isFinished() == false && curWait < maxWaitMillis) {
curWait = curWait + 100
log.debug "Waiting for move to finish: $curWait ($moveProgress.status)"
if (moveProgress.isFinished()) { "Move complete"
} else if (moveProgress.isError()) {
log.error "error during move"
} else {
log.warn "maxWaitMillis reach while waiting for move to finish."
//resume post move actions here, probably safects to re-laod your object bean after the move rather than keep the old asset object

Thanks for this answer but it didn't solve the problem.

The move now takes some millis to finish but the result is the same. All details are gone. Even the label. Line with storeObject was deleted. A clean reindex also didn't helped.

Actually the script is complete as shown above. There are no further actions. As the script is pretty simple and straight forward I have no glue.

Suggest an answer

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

👋 Looking for 15-20 volunteers to test Atlassian training content

Hi everyone! Are you interested in beta testing Atlassian University’s newest (unreleased!) training course? We’re looking for 15-20 volunteers to test our newest training course, Basic reporting...

555 views 20 25
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