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

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
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

460 views 5 18
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