Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to select using asset by AQL

Naoki
Contributor
June 6, 2025

Hi there,

Laptop and employee are managed by JSM Assets.
I add an attribute to Laptop schema to refer to employee as below:

attr.png

A laptop and a employee are stored as below:

it.png

emp.png


I want to show only laptops in use on the create service request form.
I know I can get the login user with currentUser().
But I can't get it to work in AQL.
What AQL should I write?

Thanks

2 answers

0 votes
Marc - Devoteam
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.
June 16, 2025

Hi @Naoki 

The AQL on then custom field context should be working:

objectType = "Laptop" and userInAssets."Atlassian Account ID" = ${reporter}

0 votes
Lori Brown
Contributor
June 6, 2025

I suspect that it's not tying the Employee asset to the logged in user. It knows there's an employee and it knows someone is logged in, but it doesn't tie the two together. 

If you create an attribute for the Employee and you store the Jira User in it, then you can do:

JiraUser = currentUser()

It looks like that's what you're doing with your Atlassian ID field? What was the actual AQL that failed?

Naoki
Contributor
June 9, 2025

Hi @Lori Brown 

Assets are related as follows:

asset_relation.png

After making the relation, I thought I could retrieve it in the next AQL.

However, it could not be retrieved.

 

objectType = "Laptop" AND userInAssets."Atlassian Account ID" = currentUser()

 

Can't the attribute values of linked objects be referenced in AQL?

Lori Brown
Contributor
June 10, 2025

Do you have Confluence? There's a macro "Assets" that's handy for brute-forcing AQL statements that don't behave.

This works in my environment in Confluence:

objectType = "Laptops" and Owner."Jira User" = currentUser()

"Owner" is a link to an asset of Employee type.

"Jira User" is an attribute of Employee of type "User"

If I add this query to the Filter Scope of the Assets custom field (not the Filter Issue scope field), then I get only the one result back that I expected.

In your userInAsset attribute, if you click on the three dots, is there anything on the Filter objects tab?

As a sanity check, if you change the query in your Assets custom field to just objectType = "Laptops" do you get back all Laptops?

How about objectType = "Laptops" and Owner is not empty?

And then: objectType = "Laptops" and Owner."Jira User" is not empty?

The success/failure of those might indicate if there's a syntax problem or if something about currentUser() isn't cooperating.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events