How to sum up attributes value of multiple assets in an objects custom field and update it to another Jira field using Automation

Still need help?

The Atlassian Community is here for you.

Ask the community

 

Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.

   

Summary

How to display the total cost/sum of the attribute's value of multiple assets selected in Assets objects custom field to update the Jira standard field like a text field or number field with Automation.

Environment

Jira Automation Cloud

Scenario

For example, if you have an Asset object custom field that fetches objects through an Object type that contains different Laptop assets like Dell, HP, MAC, etc and you are looking to sum the cost for the Assets in the Asset object custom field, that reflects in the Jira Field say Cost.

 

Solution

Let's assume we have a Jira text field say Cost where you need to populate the sum of the Asset object field attribute's value (say Cost) to get the total sum/cost of the Asset object field.

To achieve the use case. Kindly configure the automation rule as below:

  1. From the Automation page in Project Settings, create a rule that triggers at Field Value Changed 
  2. Next, add Create variable action and use the below syntax to sum the attribute value: 

    {{#=}}{{#<AssetObject-field-name>}} + {{<attribute-name>}}{{/}}{{/}}
    Example from my test instance:
    {{#=}}{{#Insight Object2}} + {{Cost}}{{/}}{{/}}
  3. Then, add the Edit issue action to update the Jira Field using the below smart value: {{total}}

Refer to the rule attachment below:


The above syntax iterates over every item from the Asset object field list and keeps adding its value. We had three objects in the Asset object field and we got the sum of the "Cost" attribute in the "Cost" Jira field.
In case, you need to update a field with a "Number type Jira custom field" then we need to convert the string variable "total" to a number as "{{total.asNumber}}".



Last modified on Jan 30, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.