Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Jira Assets Adding values to an attribute


Hi all!

I've written two very similar scripts for adding values to an attribute in Jira Assets.

First one works as expected - add all values (multiple) to the attribute: 


def app_1, org_1, app_2, org_2'objectType = Items AND Application IS NOT empty AND Organisation IS NOT empty').each { item ->

    app_1 = item.getAttributeValues('Application')[0].value

    org_1 = item.getAttributeValues('Organisation')[0].value'objectType = Budgets').each { budget ->

        app_2 = budget.getAttributeValues('Application')[0].value

        org_2 = budget.getAttributeValues('Organisation')[0].value

        if (app_2 == app_1 && org_2 == org_1) {

            budget.update {

                setAttribute('Items') {







On the other hand, the second one adds one value only and if there are multiple values, the previous one is replaced by the new one: 
def items = []

def budgets = []'objectType = Items AND Application IS NOT empty AND Organisation IS NOT empty').each { item ->


}'objectType = Budgets').each { budget ->



budgets.each { budget ->

    items.each { item ->

        if (budget.getAttributeValues('Application')[0].value == items.getAttributeValues('Application')[0].value &&

            budget.getAttributeValues('Organisation')[0].value == items.getAttributeValues('Organisation')[0].value) {

            // Not working as exptected with multiple objects - newly added attribute replaces the previous one

            budget.update {

                setAttribute('Items') {







Does anybody have an idea what is going on in the background? 

1 answer

0 votes
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 23, 2023 • edited

Hi @Patrik Bernát

Could you try to add some logging parameters after this:-'objectType = Budgets').each { budget ->

log.warn "======== ${budgets.size()}"

budgets.each {
log.warn "====== Budget Content: ${i}"

and see what is printed out.

The other item I have observed is that when you are doing the iteration, you are using the each approach to do the iteration. I suspect that when using each, it is only storing the last value.

Instead, could you try removing the def budgets = [] variable, update the iteration to collect(), and assign it to the budgets variable as shown below and see if there is any difference?

def budgets ='objectType = Budgets').collect()

log.warn "======== ${budgets.size()}"

budgets.each {
log.warn "====== Budget Content: ${i}"

I hope this helps to answer your question. :-)

Thank you and Kind regards,


Hi @Ram Kumar Aravindakshan _Adaptavist_ ,

thank you for your suggestion.

The collections are identical using either of the methods. Actually the part of the code with odd behaviour is this one:

budget.update {
setAttribute('Items') {

When I check the history of Assets objects, I can see the value of the attribute has changed multiple times (iteration) when running the script (second one), but only the last value is stored - the previous one is always replaced. 

On the other hand, when running the first script, the value is added to the attribute and all the other are preserved. 

I suspect it has something to do with how these objects are stored in memory, but not sure.

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events