How to Append Objects to an Assets Object Attribute using Automation

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

Summary

When using Automation for Jira's Actions to edit Attributes on Assets Objects, the values on the Attribute are cleared & replaced by the provided values.

However, there are times when simply adding to the current values is desired, and this article covers a simple solution for how to achieve this.

A more advanced method to achieve this relied on the Send Web Request Action and is covered in the following article: How to append list of objects to a reference Assets object attribute using Automation

The method in this article requires less technical knowledge to utilize.

Environment

 Automation for Jira and JSM Premium (Assets)

Diagnosis

JSDCLOUD-13045 - Provide a way to Append Values to existing Values in an Assets Object Attribute via Actions in Automation
This Feature Request asks for a built-in method to achieve the goal of adding values to an Assets Object Attribute via Automation without relying on a combination of other general functions.

Cause

When an Action like Edit Object sets the value for an Object Attribute, it expects a List. In Automation, each Smart Value has a type, such as String, List, Date, Integer, etc.

There is not currently an .append function for List Smart Values, and the Actions that edit Object Attributes do not take Strings as valid input, so combining two Smart Values, or using one Smart Value followed by a String will not work on its own.

For example, this will not work:

{{object.Attribute}},{{AssetsCustomField.Attribute}}

Even if the above resolves to a string like ABC-123,ABC-124 (two Assets Object Keys), the string won't be valid input for the Action, and it will result in an error.

Note: If the set of Objects that need to be the Attribute's Value fit an AQL Query at the moment you are editing, you can just use a Lookup Objects Action to do so, then use that smart value lookupObjects to set the Field instead.
Due to this, the Solution below isn't necessary.

Solution

To resolve this, the Create Variable Action can be combined with the .replace.split text string functions. The following are a few examples of Automation Rules that would achieve this using different methods.

The overview is that the Create Variable Action creates a String Smart Value. Then, the .split text string function turns a String Smart Value into a List. .replace is needed only to remove a space from the initial List.

In essence, we take the initial Object Attribute value, as a List, then convert it to a String and append the additional Object Keys before converting it back to a List.

Due to that being the process, it is also possible to remove values while it is a String, if that is desired, though that won't be covered here.

Edit Object via Branch on AQL with any Issue Trigger using an Issue's Asset Custom Field

  • Trigger: <any resulting from an Issue>
    In this example, the Trigger needs to be from an Issue because we will be accessing an Assets Custom Field on that Issue for some of our values.
  • Branch: AQL > <any AQL that returns Objects>
    As long as the AQL returns at least 1 object, it will work for this example.
    • Action: Create Variable > Name createdVariable:

      Variable Value:
      {{object.Attribute}},{{AssetsCustomField.Attribute}}

      The above will result in a String of ABC-123, ABC-124. This is because the returned Object from the AQL has a value of ABC-123 for its Attribute. The space is a result of how the Smart Values are rendered and will be removed later.
      Note that createdVariable, Attribute, & AssetsCustomField are all placeholders. They should be replaced with whatever your variable is named, the actual name of the Custom Field, & the actual name of the Attribute being changed.

    • Action: Edit Object > Choose the Attribute to be set, then use this Smart Value:

      Smart Value
      {{createdVariable.replace(", ",",").split(",")}}

      This takes the String and removes the extraneous space, then splits the String to turn it into a List. Since it is now a List, it is valid input for the Edit Object Action.

Edit Object with Object Trigger using a Static Value

  • Trigger: Object > Created or Updated, but not Deleted
    In this example, the Trigger is from an Assets Object being Created or Updated. This example won't work with Deleted since it needs an Object to work on.
  • Action: Create Variable > Name createdVariable:

    Variable Value:
    {{object.Attribute}},ABC-124

    The above will result in a String of ABC-123, ABC-124. This is because the returned Object from the AQL has a value of ABC-123 for its Attribute. The space is a result of how the Smart Values are rendered and will be removed later.
    Note that createdVariable & Attribute are placeholders. They should be replaced with whatever your variable is named & the actual name of the Attribute being changed.

  • Action: Edit Object > Choose the Attribute to be set, then use this Smart Value:

    Smart Value
    {{createdVariable.replace(", ",",").split(",")}}

    This takes the String and removes the extraneous space, then splits the String to turn it into a List. Since it is now a List, it is valid input for the Edit Object Action.

Edit Assets Field Attributes Action with any Issue Trigger using another one of the Object's Attribute

  • Trigger: Incoming Webhook
    In this example, the Trigger is receiving information via a Webhook Request that provides 1 Issue. It could be a Schedule Trigger with a JQL statement just the same. For multiple Issues, a Branch will be needed.
  • Action: Create Variable > Name createdVariable:

    Variable Value:
    {{AssetsCustomField.Attribute}},{{AssetsCustomField.OtherAttribute}}

    The above will result in a String of ABC-123, ABC-124. This is because the returned Object from the AQL has a value of ABC-123 for its Attribute. The space is a result of how the Smart Values are rendered and will be removed later.
    Note that createdVariable, Attribute, & OtherAttribute are placeholders. They should be replaced with whatever your variable is named & the actual names of the Attribute and OtherAttribute being changed.

  • Action: Edit Assets field attributes > Choose the Attribute to be set, then use this Smart Value:

    Smart Value
    {{createdVariable.replace(", ",",").split(",")}}

    This takes the String and removes the extraneous space, then splits the String to turn it into a List. Since it is now a List, it is valid input for the Edit Object Action.

Lookup Objects

It is not possible to directly edit Objects using Edit Object or Edit Assets field Attributes Actions from a Lookup Objects Action. Due to this, use an AQL Branch instead.

This is because those Actions do not recognize the Objects returned by the Lookup Objects Action.

Further Reading




Last modified on Jan 31, 2025

Was this helpful?

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