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

Create an automation to count with sum of items from a single select custom field

Elizabeth Pfotzer December 1, 2022

I want to automate the steps to count and generate a sum of a specific custom field. The custom field is a single select list. There is a secondary custom field to contain the sum.

This is the automation rule as I have tried it so far:

Trigger: When Value changes for (name of custom field), then Change Type is Value added.

The For field is left blank >

Then: Edit issue fields, choose secondary field that will hold the sum with this value:

value= {{issue.customfield_10241.size}}

Unfortunately, nothing happens after that, no sum, no total, nada...

Pls let me know if you've got a resolution. Send to Atlassian - Automation Question - Dec 1.png

2 answers

2 votes
Mark Segall
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 1, 2022

HI @Elizabeth Pfotzer - There are a few pieces to this that I need to understand:

I want to automate the steps to count and generate a sum of a specific custom field. 

Is this across a number of issues or does the custom field have options that are captured in an array of some sort (e.g. 1, 2, 3, 4)?  

Then: Edit issue fields, choose secondary field that will hold the sum with this value:

value= {{issue.customfield_10241.size}}

This is not how the edit issues action works or the way the size smart value works.  Edit issues would simply be {{issue.custom_field_10241.size}}.  However, size is intended to provide a count of an array (hence my first question for clarity).  For example, I use the lookup issues action and use {{lookupIssues.size}} to get the count of how many issues were returned by the lookup issues action.  

 

Elizabeth Pfotzer December 5, 2022

@Mark Segall - thanks very much for your reply. To try to clarify for you, I have a CSV file that has a a heading "Component" which refers to the component of a vehicle. I am attempting to count the number of each different component that is uploaded through the external system upload. For instance, if "Oil Cooler" occurs 300 times in the CSV file, I want to quantify that number and be able view it in the custom field called Component Count field in Jira. Ultimately, I want to create a filter and display it on the dashboard.

I created the single select dropdown custom field called "TEST - For Component Count" that has the names of the components so that when a new issue is created, the name of the component is selected from that field and the count would then go into the Component Count field.

I hope this is clear?

Mark Segall
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 5, 2022

Thanks for the additional clarity... Do each of the rows in the csv correlate to an individual Jira Issue or does each issue get its own csv?  

If the former, you probably want to create a "master issue" for each component that stores the total count.  You could do something like this:

  • TRIGGER: Manual 
    We'd execute this against your master issue
  • ACTION: Lookup Issues:
    • Component = "Oil Cooler"
  • ACTION: Edit Issue (Component Count)
    • {{lookupIssues.size}}

If each issue gets its own csv, you'd probably want to explore upgrading JSM to Premium so you can take advantage of Asset Management.

0 votes
Charlie Misonne
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 5, 2022

Hi Elizabeth,

When you set the value for a custom field you should not include the "value = " part. I'm not sure where you got that from?
{{issue.customfield_10241.size}} should be sufficient. I never used "value ="

Perhaps using the Log action task will help you. With this task you can log something that will be visible in the log of your rule to make sure the number you are expecting is correct.

You should also clear the additional fields section because that field expects a json representation.

The name of the field you are setting is component count so I assume you want to display the number of selected components in a select list. And this is not the default components field from Jira?
Or is it an actual select list of numbers? In that case .size will not be the right method to use as @Mark Segall pointed out.

 

This is a working example where I set the number of selected components in the description of the ticket.

2022-12-05 16_09_06-Automation - Jira Service Management.png

More info:

Documentation on math expressions: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-math-expressions/

And the one for lists: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-lists/

Suggest an answer

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

Atlassian Community Events