Hi,
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 com.riadalabs.jira.plugins.insight.services.model.move.MoveObjectMapping
import com.riadalabs.jira.plugins.insight.services.model.move.MoveAttributeMapping
import com.riadalabs.jira.plugins.insight.services.model.move.MoveObjectBean
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)
moveMap.map(59,MoveAttributeMapping.create(fromAtts.find{id=59},toAtts.find{id=59})) // Key
moveMap.map(259,MoveAttributeMapping.create(fromAtts.find{id=259},toAtts.find{id=259})) // Artikelnummer
moveMap.map(60,MoveAttributeMapping.create(fromAtts.find{id=60},toAtts.find{id=60})) // Artikelname
moveMap.map(61,MoveAttributeMapping.create(fromAtts.find{id=61},toAtts.find{id=61})) // Created
moveMap.map(4522,MoveAttributeMapping.create(fromAtts.find{id=4522},toAtts.find{id=4522})) // Hersteller
moveMap.map(62,MoveAttributeMapping.create(fromAtts.find{id=62},toAtts.find{id=62})) // Updated
moveMap.map(4839,MoveAttributeMapping.create(fromAtts.find{id=4839},toAtts.find{id=4839})) // Gewicht
moveMap.map(403,MoveAttributeMapping.create(fromAtts.find{id=403})) // Kategorie
def mObject = new MoveObjectBean()
mObject.setFromObjectTypeId(asset.objectTypeId)
mObject.setObjectSchemaId(3)
mObject.setToObjectTypeId(20)
mObject.setMapping(moveMap)
mObject.setReferences(mObject.references.valueOf("KEEP_REFERENCES_TO_OBJECT"))
mObject.setIql("Key = " + asset.objectKey)
im.objectFacade.moveObjects(mObject)
im.objectFacade.storeObjectBean(asset.createMutable())