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

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


1 badge earned


Participate in fun challenges

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


Gift kudos to your peers

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


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!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

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)


3 answers

1 accepted

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

@Christof Hurstdid you find solution for this? In my case move is working, but also attributes are gone after moving an object form one typeId to another (in the same schema).

Solution is in the accepted answer. If attributes are missing I would presume that they are not in the list to be copied or not with the correct data or data format.

I am using .each function and not mapping them manually with IDs, but I get the same result with your example and mapping them manually.

toAtts?.each { item ->
MoveAttributeMapping temp = MoveAttributeMapping.create(item, fromAtts[index]);[index].id, temp);


After I've done the mapping my MoveAttributeMap object shows like this:

moveObject: MoveObjectBean{fromObjectTypeId=69,
iql=Key = KAS-132313,

 Which looks like the mapping is done correctly, no?

The index variable is undefined. Can't work.

def index = 0; is set before this each loop.

Sorry I don't know. I know that my method is working. I would never trust this automatic way. I always define the set of attributes explicitely by myself.

0 votes

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.

@Christof Hurstdid you find solution for this?

My attributes are gone too after a successful object movement from one typeId to another.

Then I think finding the correct value in the old object is not working. For me it was = instead of ==

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events