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
I solved this problem with the following steps in Automation.
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
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
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.