Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Appending Asset objects to an Asset custom field using Automation

C_ Derek Fields
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 12, 2024

Problem Statement:

I have an Asset custom field that takes multiple objects. I need an Automation that allows the user to create a new Asset and add it to the values already in that field.

The problem is how to append this new asset to the existing list of assets in that custom field

Solution:

I solved this problem with the following steps in Automation.

Step 1: Get the information from the user in a Manual Trigger to create the object

Step 1.png

Step 2: Do a lookup in the Schema to see of the object already exists

I don't want to create duplicates, so I do a look and make sure that I don't find any objects that match. If there are none, then I create the new Object

Snag_3177037.png 

Step 3: Do a second lookup 

If I created the object, then I need to look it up in the database. This ensures that I have the new object in lookupObjects list. I use the same lookup as I did in Step 2

Snag_319be5d.png

Step 4: Add the new object to the current list of objects in the custom field

This is the "trick". When using "Edit Issue" on an Assets field, you need to provide an AQL statement to return the values that you want to add. This AQL adds the newly created asset object to the current list.

Key in ({{if(issue.company contact.size.gt(0),issue.company contact.join(",").concat(","))}}{{lookupObjects.get(0)}})

This AQL to see if the current field is empty. If it is not empty, then we get the current set of values and join them with a comma-separation and add a comma at the end of the string. Then we add on the newly created object. This is all set within () so that AQL sees it as a list of Keys. 

An example of the generated AQL is

Key in (PERMIT-8018,PERMIT-8013)

This returns the keys of the existing object(s) as well as the key of the new object and sets them into the custom field.

0 comments

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events