Loop over asset objects and update them using Jira Automation
Asked by Sidharth verma:

Hi,

I have asset objects created as below :

Name Assigned

A 0

B 0

C 0

I want to loop over all the above asset objects and update the assigned value to 1 based on the issues assigned to the team members i.e. If team member A is assigned an issue it should update the assigned value to 1.

typically, updating an asset object can be done using AQL branching and thats what i tried in the below automation:

![Screenshot 2024-07-17 140623.png](/t5/image/serverpage/image-id/336043iB164A720A796928C/image-size/large?v=v2&px=999 "Screenshot 2024-07-17 140623.png")

In the above automation i am looping through my asset object "Cummins Deployment Team" and then querying the team members name using lookup issues and accessing the team members name as {{Object.User}}. However, {{Object.User}} returns all the users rather than the first one and hence the query also doesn't return anything. How can i ensure that I can loop through the objects one by one and query them with lookup issues?

Please let me know if there is any workaround for the same.


Answers:
author: Sidharth verma
body: It is working now thanks.


author: Kris Dewachter
body: Hi [@Sidharth verma](/t5/user/viewprofilepage/user-id/5442718) ,

At first sight, your automation rule seems to be setup correctly.

The audit logging in automation rules is a bit confusing if your AQL results in multiple found objects. Your log action will display all found objects.

But your "Lookup Issues" will be executed for each individual object. And thus you can also process each result individually.

I'm not sure what you do exactly in the last "edit object attributes" exactly. That's not visible in your screenshot.

Best regards,

Kris

comments: author: Sidharth verma
body: Hi [@Kris Dewachter](/t5/user/viewprofilepage/user-id/4588367)

Attached is the log output for the above rule:

![Screenshot 2024-07-19 233816.png](https://community.atlassian.com/t5/image/serverpage/image-id/336762iA3740B9CCEC830D2/image-size/large?v=v2&px=999 "Screenshot 2024-07-19 233816.png")

(Please ignore the delay statements I have just put it to try something)

let me explain in brief on what i am doing:

1.) Return multiple Asset objects using the advance branching AQL statement.

2.) Loop through each object one by one. Ideally in the first iteration object should return only first object and will access the attribute user of that using {{Object.User}} statement. However, as per the above log it is returning all the objects.

3.) Lookup issues using a JQL query with the {{Object.User}} as argument. however, as per above log it doesn't return any issues as all the users are returned.

4.) Edit the asset object attribute "Assigned" and add the value as Number of issues found from JQL query i.e. {{lookupissues.size\|0}} value.

I think the main problem is all the users are returned when i use {{Object.User}} inside the loop. Not sure how to access the object one by one inside the loop?


author: Kris Dewachter
body: Hi [@Sidharth verma](/t5/user/viewprofilepage/user-id/5442718) ,

I agree with you that it would be ideal if the automation log would display each object individually. But unfortunately, it will not. All objects will be displayed together in the log as you see now. There is no way to improve that.

I can see in the audit log that a search was performed, and the objects where successfully updated. That's the good news.

However, I can see the objects have been updated with value 0, and the query states the lookup action "found no issues". So i'm presuming there is some kind of error in the JQL. Can you validate if the JQL is correct by constructing it in a variable in the automation rule, and display the constructed JQL in the audit log ? Then, you can copy/paste this in the Jira issue search and check if it produces any results.

Best regards,

Kris


author: Sidharth verma
body: Hi [@Kris Dewachter](/t5/user/viewprofilepage/user-id/4588367)

as suggested i constructed the query into a variable and added in the log. looks like the query was correct. However, i was using the property {{lookupissues.Size}}, which was incorrect as it was case-sensitive.

when i changed it to {{lookupIssues.size}} it took the correct values and updated them in Assets. Thanks for your suggestion !!![Screenshot 2024-07-22 192339.png](https://community.atlassian.com/t5/image/serverpage/image-id/337040iE3FF15A4EE95AB10/image-size/large?v=v2&px=999 "Screenshot 2024-07-22 192339.png")

However, one strange thing is there in the above log that it still showing that lookupissues did not find any issues. but when we access the number of issues using {{lookupIssues.size}} it is getting the correct number.


author: Kris Dewachter
body: Hi [@Sidharth verma](/t5/user/viewprofilepage/user-id/5442718) ,

I'm not sure but i think the "lookup Issues" action only logs the result of the first ticket (PT-131).

Best regards,

Kris


Tags: assets

cloud

jira-service-management

jira-service-management-cloud