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

Groovy script to move objects to another schema


I am looking for a way to keep a history of the objects that are removed from the sources. I want to move them to a new scheme.
I want to do it with an automatic rule that calls a script.
I have tried the following code to move the objects to this new schema which is a clone of my main one. But dosen't work

Class objectSchemaFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("");
ObjectSchemaFacade objectSchemaFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectSchemaFacadeClass);

Class objectTypeFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("");
ObjectTypeFacade objectTypeFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectTypeFacadeClass);

List<ObjectTypeBean> crcAllObjectTypes = objectTypeFacade.findObjectTypeBeansFlat(1)

ObjectTypeBean srcObjectType = crcAllObjectTypes.find
{ o -> == object.objectTypeId}

Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("");
ObjectFacade objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass);

Class objectTypeAttFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("");
ObjectTypeAttributeFacade objectTypeAttFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectTypeAttFacadeClass);

MoveObjectMapping moveMap = new MoveObjectMapping();
List<ObjectTypeAttributeBean> fromAtts = objectTypeAttFacade.findObjectTypeAttributeBeans(;
List<ObjectTypeAttributeBean> toAtts = objectTypeAttFacade.findObjectTypeAttributeBeans(407);

def index = 0;

{ item -> MoveAttributeMapping temp = MoveAttributeMapping.create(item,fromAtts[index]);[index].id,temp); index++; }

MoveObjectBean mObject = new MoveObjectBean();

try { mObject.setIql("Key = " + object.objectKey); objectFacade.moveObjects(mObject); // objectFacade.storeObjectBean(object) }
catch (Exception vie)

{ log.warn("Could not update object attribute due to validation exception:" + vie.getMessage()); }

0 answers

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events