Set a Custom Field (Assets object) using Jira automation
Asked by Scott Bickerton:

We have a custom field (in this example - "Related Control") which is configured to link to a Jira Assets object, but would like to set the value in certain automations.

For example, suppose we have a Request type which always relates to a Cryptography control, we would like to set this automatically when a request is raised.

The field works fine when setting manually - it is configured to link to a particular schema, and when manually editing a ticket it is possible to select multiple values, as expected.

![Screenshot 2024-03-28 at 12.01.04.png](/t5/image/serverpage/image-id/315104i540D928A05510ECC/image-size/large?v=v2&px=999 "Screenshot 2024-03-28 at 12.01.04.png")

When using automation, I can retrieve the attributes of Assets objects using AQL, and use these in further automation, but I am unable to set the custom field to the Assets object.

When using the "Edit Issue Fields" action, selecting the "Related Control" field in my example prompts for AQL:

![Screenshot 2024-03-28 at 12.05.31.png](/t5/image/serverpage/image-id/315106iF51BC5359450BA30/image-size/large?v=v2&px=999 "Screenshot 2024-03-28 at 12.05.31.png")

When clicking on "Validate Syntax", the following pop-up appears, regardless of the AQL entered:

![Screenshot 2024-03-28 at 11.43.07.png](/t5/image/serverpage/image-id/315107iE6DCDD67C4EE2719/image-size/large?v=v2&px=999 "Screenshot 2024-03-28 at 11.43.07.png")

I have tested using multiple AQL queries, but get the same error. I am, however able to retrieve the object values using the same AQL in a "Lookup Objects" action.

I have checked the custom field configuration, and I am searching on attributes which are searchable

![Screenshot 2024-03-28 at 12.11.49.png](/t5/image/serverpage/image-id/315109i9EDEB01ABF39FCA5/image-size/large?v=v2&px=999 "Screenshot 2024-03-28 at 12.11.49.png")

Has anyone else experienced this issue, or have any suggestions of another method to automate the population of the custom field with the appropriate Assets object.


Answers:
author: *ServiceRocket* KL Foong
body: Hi [@Scott Bickerton](/t5/user/viewprofilepage/user-id/5030952)

The validate function has a bug [Assets Automation: Validate Syntax for Object Attributes in Automation is failing](https://jira.atlassian.com/browse/JSDCLOUD-11372)

If the AQL in a "Lookup Objects" action works fine, it can be used in Edit Issue action without validation.

comments: author: Scott Bickerton
body: Sorry for the delay in marking this query as resolved. There were a couple of contributory issues.

Firstly, as [@\*ServiceRocket\* KL Foong](/t5/user/viewprofilepage/user-id/5403002) states, the "Validate Syntax" option doesn't work in this scenarion, however the AQL works fine and returns objects which can then be used for further automation.

Secondly, when I initially had issues, I was attempting to search on an attribute which wasn't searchable in the custom field configuration. Making the attribute searchable fixes that issue.


author: Danielle Alota
body: Heya [@Scott Bickerton](/t5/user/viewprofilepage/user-id/5030952) and anyone that's stumbling across this.

TLDR; I think you're looking for the keyword 'Key'. The Lookup Object action returns the object key (eg. ABC-1111}. So when creating/editing an issue with assets as a custom field, you're looking to do:

key = {{lookupObjects}}

*** ** * ** ***

I ran into this issue just today. My use case was that I needed to create new issues every week for each asset with objectType = "Office".

eg. Name = Office Sydney

Abbreviation = SYD

To test, I used Lookup Object action and AQL to find the object: objectType = Office and "Name" = "Office Sydney". This gave me PRP-123, and I was able to do {{lookupObject.Abbreviation}} to get SYD.

In my Create Issue action, I selected the assets custom field "Office". For the AQL, I used key = {{lookupObjects}} and it linked the issue to the object.

I hope this helps!


author: Bao Truong
body: My solution involves using the 'key in(object)' function.

![Screenshot 2024-05-30 at 17.59.15.png](https://community.atlassian.com/t5/image/serverpage/image-id/326939i982D86EE0D02E181/image-size/large?v=v2&px=999 "Screenshot 2024-05-30 at 17.59.15.png")![Screenshot 2024-05-30 at 18.00.15.png](https://community.atlassian.com/t5/image/serverpage/image-id/326940iB7880B7203961877/image-size/large?v=v2&px=999 "Screenshot 2024-05-30 at 18.00.15.png")


Tags: cloud

jira-service-management

jira-service-management-cloud