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

Move Insight Object from one Object Type to another in post function Edited


I'm trying to move an Insight object from one object type to another. Of course, if you are using the interface, this is no problem. But we want to move an object in a post function. The background of this is that we have a JIRA process that handles Hardware exchanges. At a certain status the user is asked, if the "old" Hardware should be scraped or put back in the pool for further usage.

If the user chooses "Scrape" the Hardware will be moved to the object type "Deprecated Hardware". With this, we can still access the old hardware in the Insight Backend, but remove the object from being chosen by a user during a "New User" Workflow.

I'm using the code below, and it does actually move the object (I'm using JMWE Groovy Script), but unfortunately without any values, but I can't figure out, where the problem in my code is. Help is much appreciated.

Thanks a lot, Michael

import com.atlassian.jira.component.ComponentAccessor;

/* Get Insight Object Facade from plugin accessor */
Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("");
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass);

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

def moveMap = new MoveObjectMapping();
def fromAtts = objectTypeAttFacade.findObjectTypeAttributeBeans(826);
def toAtts = objectTypeAttFacade.findObjectTypeAttributeBeans(832);
def index = 0;

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

def mObject = new MoveObjectBean();


def insightObjects = issue.get("Old asset");

if (insightObjects != null) {
insightObjects.each{insightObject ->
/* Move object/s */
try {
mObject.setIql("Key = " + insightObject.objectKey);
} catch (Exception vie) {
log.warn("Could not update object attribute due to validation exception:" + vie.getMessage());

return true

1 answer

Hi Michael.

You have to map every attribute from the source to the destination - and the type must match between source and target attributes...

The best way to understand the Move Object is to follow the Bulk-Move UI - the same should be done in your script.

Missing attributes won't be moved if not specified.

Kind regards,


Team Riada

Hi @Yinon Negev ,

I faced pretty the same challenge @Michael Aydemir  was dealing with. Unfortunately, I'm not sure I did follow your hint exactly the way you were describing. Let me describe the issue, what is it current status and ask you for piece of code if possible :)

We are storing important kind of data in CRC object schema.
Because of the importance, we don't want anyone to operate manually.
Operations like new object creation or update are fully automated. Unfortunately, objects "removal" has to be done manually. We'd like to automate it.

There are 3 main object types:

  • Register Objects
  • Attribute Objects
  • Removed Objects
    Attribute Objects are only reference objects.
    Register Objects are our main objects. Once object is removed from Register Objects, it is moved to Removed Objects.
    Register Objects and Removed Objects hierarchy is the same. The difference is only in child type names that are prefixed with "Removed" in Removed Objects. Attribute list, their types and type values are the same, so manual action is just few clicks.

Here is one of my try, mainly based on this post.
Object is moved but without any attribute. It's searchable by it's label, but none attribute displayed and none attribute is saved when object edited manually.
Wondering if anything should be done with Progress object returned by moveObjects method ( but was not able any clue for that :/


skipping imports and issue load
def object = (issue.getCustomFieldValue(cfObject)[0]).createMutable()

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

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

ObjectSchemaBean crc = objectSchemaFacade.findObjectSchemaBeans().find

{ o -> o.objectSchemaKey == 'CRC'}

List<ObjectTypeBean> crcAllObjectTypes = objectTypeFacade.findObjectTypeBeansFlat(
ObjectTypeBean srcObjectType = crcAllObjectTypes.find

{ o -> == object.objectTypeId}

ObjectTypeBean tgtObjectType = crcAllObjectTypes.find

{ o -> == ('Removed ' +}

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(;

def index = 0;

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

MoveObjectBean mObject = new MoveObjectBean();
// mObject.setReferences(mObject.getReferences().valueOf("REMOVE_REFERENCES_TO_OBJECT"));


{ 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()); }

Like Fredrik Elmqvist likes this

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Marketplace Apps & Integrations

5 mobile apps for Jira Cloud to boost productivity

  It’s very important to have access to the workflow process from anywhere. Especially if you manage the work of others. There is no difference whether you’re out of office, or drive a ca...

240 views 2 5
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