How to bulk clone Assets objects to a different object type or schema using Automation
Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.
Summary
Currently, in the Jira Service Management Assets tool, it is not possible to move objects to a different object type, and the Clone action can only create objects in the same object type as the original. With the help of Automation, we can create a process to bulk clone objects to a different object type or a different object schema, which can save you some time when moving objects is a necessity so you won't have to manually recreate all objects.
Some things to keep in mind when using this workaround:
- The object key will not be the same on the cloned objects, so Assets object fields that have the original objects stored in them might need to be updated with the new ones. The following article can help you bulk update existing values on Assets fields:
- You might need to create a new Assets object field or adjust an existing one to show the objects that were created via this process.
Creating the setup
Before we can create and execute the automation rule, we need to make sure that the target object type has all of the attributes that the original object type has. For example, in the image below you can see that OldObject has the Warranty and User attributes (aside from the default ones):
So in the NewObject I'll also add the same attributes:
Creating the Automation Rule
Now that the object type setup is complete, we can create the automation rule to clone/move the objects from OldObject to NewObject.
Go to System (Cog Icon) > Global Automation (on the panel to the left) and start a new rule with the following components:
Scheduled Trigger: We use the scheduled trigger so we can execute the rule as needed. The schedule itself is not really important, but be aware that depending on how you configure it the rule might be triggered again. Ideally you should disable the rule after using it, and enable it again in case you need to use it in the future.
Branch on AQL: Select the schema where the objects reside and use the "Query" field to add an AQL that will narrow down the results. In this example, I only want to clone/move the OldObject object type assets, so I'll filter by adding "objecttype = OldObject". Feel free to add as many AQL statements as needed for your use case. For more information on how to build AQL statements, please check the Use Assets Query Language (AQL) article.
Create Object: Select the target object schema and also the target object type where the objects will be created. After that, also select all attributes that will be copied over to the new objects and use the {{object.AttributeName}} smart value but replace <AttributeName> with the actual name of the attributes from the old objects.
After saving all of the changes, don't forget to name your automation rule and publish it by clicking on Turn it on:
After that, simply run the rule by clicking on the Run Rule button at the top right corner:
The objects should be copied over to the new object type and schema:
Currently, due to the following limitation, it's not possible to update more than 50 objects in a single Assets automation run:
For this reason, you might need to run the rule multiple times depending on the number of objects you need to clone.