Forums

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

Automation: AQL branching issue

Tomislav Tobijas
Community Champion
January 29, 2024

What are we trying to achieve?

We have employee IT equipment stored inside Assets. On each asset/object, you have an attribute stating current employee/owner of that asset. What our Asset managers would like to 'see' is when they navigate to 'people' object, to see which assets they have previously owned, together with assets they currently own.

Regarding assets they previously owned, the idea is to have additional attribute on each asset pointing to "people" object type that can also store multiple values as asset can be owned by multiple people during its existence.

The setup

We are looking at two object schemas - one for people/users with 1 object type "People", and one for IT assets containing multiple object types (e.g., "Laptops", "Mobile phones"...)image.png

👉Additionally, have an automation in our JSM project which automatically updates current owner (removes the user from the IT asset attribute) once ticket (request type "Return your asset(s)) reaches specific status in a workflow.

The issue

Imagine that the JSM ticket has 2 objects (let's call them Object 1 and Object 2) linked and I'm owner of both of these objects. Both of these objects had previous owners where "Object 1" had Person A as a previous owner and Object 2 had Person B as previous owner.

Now, the automation should do the following - once ticket reaches specific status, remove current owners from both objects (this part works okay), and change the value of Previous owner(s) attribute by only adding "current" owner to the list. So, after the automation is done, we should have something like this:

  • Object 1 ("Previous owner(s)"): Person A, Tomislav Tobijas
  • Object 2 ("Previous owner(s)"): Person B, Tomislav Tobijas

Automation is using the following solution for appending the values to object attribute: https://confluence.atlassian.com/jirakb/how-to-append-objects-to-an-assets-object-attribute-using-automation-1283493731.html

2024-01-29_11-40-19.png

Now, according to rule logs, created variable is correct upon creating but once it is used in Edit Assets field attribute action, it updates both objects with 'same' values and I end up with the following result:

  • Object 1 ("Previous owner(s)"): Person A, Tomislav Tobijas
  • Object 2 ("Previous owner(s)"): Person A, Tomislav Tobijas (❌ not ok)

2024-01-29_12-03-14.png

I'm wondering if I'm missing something here? Does the automation and (AQL) branching work in a way that if there are multiple objects inside branch:

  1. Iteration 1: For object 1 > create variable
  2. Iteration 1: For object 1 > update attributes
  3. Iteration 2: For object 2 > create variable
  4. Iteration 2: For object 2 > update attributes

Or does it work in some other mysterious ways? 😅

Any help would be appreciated 🙌
Cheers!

2 answers

1 accepted

1 vote
Answer accepted
Bill Sheboy
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.
February 5, 2024

Hi @Tomislav Tobijas 

First thing, a disclaimer: I am not using JSM or assets with rules, and so my suggestions are based on what I know about rules and not those products / features of Jira.

Inside the branch, your rule appears to create a variable with the same name twice in a row, although I cannot see the details of the value being set.  What is the purpose of those actions?

Until that is clarified...

Please note that branches which could process more than one thing are run in parallel and asynchronously.  And there is no guarantee of when the branch will complete, up to the last step of the rule.

What this means is things which happen inside that type of branch stay inside of there, and cease to exist outside of each iteration / loop.  The exception is anything written / saved to the cloud.  If you are expecting that variable to persist and be updated, that cannot happen.

Kind regards,
Bill

Tomislav Tobijas
Community Champion
February 6, 2024

@Bill Sheboy my apologies then for dragging you into this!

Regarding this:

Inside the branch, your rule appears to create a variable with the same name twice in a row, although I cannot see the details of the value being set.  What is the purpose of those actions?

In the first action, we just wanted to 'reset' the variable to see how the system will behave. Feel free to ignore this part as I've removed this first Create variable action and left only the 'second' one (stated in original post).

2024-02-06_09-30-29.png

When it comes to this:

What this means is things which happen inside that type of branch stay inside of there, and cease to exist outside of each iteration / loop.

In my case, it seems that variables from different branches somehow overlap (at least that's how I see it) and there is no clear pattern when or how it works. When you have two objects where "Previous owner(s)" are the same people, it works okay. But when they are different users (whether one or multiple), I usually get different results. I've tested multiple iterations where I've changed "Previous owner(s)" values and here are the results: https://koios.atlassian.net/wiki/external/MTk4ZGQyMGJkNmY2NGYyYzg1OTk3ZjlhNzFkNmQ0MDg

One more thing - can you clarify this?

The exception is anything written / saved to the cloud.

Cheers,
Tom

Bill Sheboy
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.
February 6, 2024

The values of variables for each iteration / loop of the branch on the AQL are definitely distinct.  If the values overlap, that would be related to:

  • the AQL used for the branch (and so the objects returned), and / or
  • the smart value expression used to create the variable

And so the double updates you note are likely caused by the overlap, and the unpredictability of results from the parallel processing nature of loops.

The solution is to somehow adjust those two things above to process each item one time.

 

About this...

The exception is anything written / saved to the cloud.

If inside of a branch it updates an issue (or object) that persists, stored in the cloud.  The other things inside of the branch (e.g. variables created) no longer exist after the branch runs each loop.  Sorry if the original post was a bit vague :^)

 

Tomislav Tobijas
Community Champion
February 6, 2024 edited

Ugh... I can be such a potato-head sometimes 🤦‍♂️

Before I added branching/iteration, the action for updating assets/objects was Edit Assets field attributes. As, initially, we only had one asset linked to an issue, that was fine. I forgot to take in consideration that this actually updates all assets in specified Jira field, even if there are multiple objects added.

Once the iteration was added, variable creation and branching was okay, but in each iteration, automation action would update both objects and not only the one from current iteration.
Basically, the only thing I had to do is to replace mentioned action with Edit object attributes (which actually looks current object from branch iteration), and everything worked like a charm.Replace action.png

@Bill Sheboy , thanks for the help here! I needed second pair of eyes and the guidance you provided to resolve this. Much appreciated 😄

Like Bill Sheboy likes this
Majken Longlade
Contributor
April 10, 2024

Thanks for figuring this out, I was literally just trying to figure out the same thing!

The docs on using Automation with Assets are no where near sufficient.

Like Tomislav Tobijas likes this
0 votes
Tomislav Tobijas
Community Champion
February 5, 2024

@Bill Sheboy mind checking this out if you find the time?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events