How to copy values between Assets object field and multi-select custom field using Automation

Still need help?

The Atlassian Community is here for you.

Ask the community


Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.

Summary

There can be scenarios where customers have a multi-select custom field that captures assets and the workflow involves copying/adding these assets to an Asset object custom field. Some Situations might also involve copying them from an Asset object custom field to another type of custom field.  This kb covers both scenarios and lists the steps that can be followed to achieve this use case via automation. 

Environment

Automation for Jira and JSM Assets

Solution

Use case 1: Copy values from a multi-select custom field to an Asset object custom field

Let's take an example where you would like to copy the values from a multi-select custom field called "List of software" to an Asset object field "Software" that can store multiple objects of object type "Software". The options of the multi-select field match the "Name" attribute of the Software objects. 

For example, the multi-select custom field has values set as "Software 1" and "Software 2". The automation rule should copy these values to the Asset object custom field.

To edit an Asset object custom field via automation, an AQL is provided. To get the desired list of objects, the AQL should look as below:

objectType = "Software" AND Name IN ("Software 1", "Software 2")

We need to manipulate the values selected in the multi-select custom field in the format "Software 1", and "Software 2" and then copy them into the Asset object field.

Follow the below steps:

  1. Create an automation rule and set the trigger as required.
  2. Click on New action > Create variable. Create a variable called "Asset1"(use any name you want) to store the below smart value:

    {{#issue.select list multiple}}"{{value}}"{{^last}},{{/}}{{/}}

    This will fetch the values from the multi-select field which is stored as a list and the output will be in the desired format which can then be used in our AQL. To know more about accessing list values and formatting them, you can refer to this article. 

  3. Add a log action to make sure we get the desired results:

    List of Softwares: {{Asset1}}
  4. Click on New action > Edit issue. Choose your Asset object custom field and specify the below AQL:

    objectType = "Software" AND Name IN ({{Asset1}})

Before execution                                                                                                                    

 Execution Audit log                                                                                                                          

After execution                                                                                                                     


Use-case 2: Copy values from Asset object custom field to a multi-select custom field.

Let's say you have an Asset object field "Software" that stores the list of Software installed on a system that can hold multiple objects. Also, you have a multi-select custom field called "List of software" which has options that match the "Name" attribute of the Software objects. You would like to copy the values from the "Software" Asset object custom field to the "List of softwares" multi-select custom field.

Below are the steps to achieve this scenario:

  1. Create an automation rule and set the trigger as required.
  2. Click on New action > Edit issue action and in the advanced fields section add the below:

    {
        "fields": {
            "List of softwares": [{{issue.Software.Name.flatten.asJsonObject("value")}}]
        }
    } 


Please feel free to reach out to support if you have any questions.

For more examples about how you can use Automation with Assets refer to the article: Update Insight object attribute values using automation

Last modified on Jan 26, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.