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

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

Avatar

1 badge earned

Collect

Participate in fun challenges

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

Challenges
Coins

Gift kudos to your peers

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

Recognition
Ribbon

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!

Leaderboard

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
4,465,953
Community Members
 
Community Events
176
Community Groups

JMWE error "expected a number but got" on a sum() event-based calculation.

I am new to using JMWE and I probably have the syntax incorrect but I cannot figure out what is wrong.

I have an issue type named shipment in which a number field is entered with the number of samples in that shipment.

This issue type is under an epic.

I would like a total number of samples field to be shown on the epic view screen where it is continually updated every time the number of samples field is updated in any shipment for the epic.

This is what I did. But the field still says None. I even went to a shipment and switched a number and switched it back to hopefully trigger the calculation and still nothing. Can you help to clarify what I am misunderstanding? The error it states: "expected a number but got: | sum({issue.fields.customfield_10083})"

image.png

 

1 answer

1 accepted

0 votes
Answer accepted

Hi @Sally Wheeler ,

the correct syntax for the value would be:

{{targetIssue | stories("customfield_10083") | field("fields.customfield_10083") | sum }}
  •  targetIssue represents the target issue (the parent Epic of the current issue)
  • | stories("customfield_10083") returns all Stories of that Epic, returning only the customfield_10083 custom field (for efficiency)
  • | field("fields.customfield_10083") returns an array of the value of the customfield_10083 field for each Story
  • | sum sums up the values in the array

Thank you. @David Fischer _Appfire_  I really appreciate you breaking down the syntax. I am new to using the language and am struggling. Even the documentation that is provided does not breakdown when you have to work with different issue levels. 

It is now giving the error "NaN". I do have the total field configured as a number as well as the fields that we are pulling. Do you know what could be causing this?

@David Fischer _Appfire_  I also have different stories of which this field is not present in. Is there a way to specify the story? I feel like this might be the issue. 

image.png

 

I would like this to run on "Incoming Shipment"

@Sally Wheeler that is indeed the reason. We have pushed a small improvement to ignore null values in the sum filter which should fix your problem.

@David Fischer _Appfire_ Is there anything I can do now to get this to work prior to waiting on the fix? Can I specifically call the issue type name?

Did you try again after my last comment?

Can you tell me the syntax for if I wanted to take this one step further and only grab field for a certain label? @David Fischer _Appfire_ 

Hi @Sally Wheeler ,

that's a little more complicated. I assume you mean that you want to sum the value of the field only on Stories of the parent Epic that have a certain Label, correct?

In that case, the script would be something like:

{% set total = 0 %}
{% for story in targetIssue | stories("customfield_10083,labels") %}
{% if story.fields.labels.includes("mylabel") %}
{% set total = total + story.fields.customfield_10083 %}
{% endif %}
{% endfor %}
{{total}}

Hi @David Fischer _Appfire_ I apologize, I should have elaborated. Yes in general. It is actually value of the field on a subtask of a story to be reported out on the story. 

The story level is called Invoicing Matrix. The subtask is called Milestone. (All still under the Epic, but I don't think we need to go that far since I am reporting out in the story level)

I am building out an invoicing workflow where there are Milestones (has its own workflow) that are captured in the Invoicing Matrix (has a broad stroke workflow). 

What I am trying to create is a custom log of the Milestones. Where monthly, the number of Milestone per month is invoiced and stored in a field "#accrued" and "date accrued". I would like to create a log of when this field is populated and potential clear the field to be available for a new entry. In the log, I would like to also sum the #accrued of the milestone over time as "total accrued".

I was thinking of using your solution above for the last part but I do not even know if the log is feasible. And if it is not feasible, then I need to find a way to capture a repeated use of a "Milestone". Maybe a circular point in the workflow, where I use a post function in the transition to clear the field (if possible). But I would still need a way to capture the history. If you have any ideas, it would be appreciated.

   

Hi Sally,

I'm not sure I fully understood your requirements, and they seem fairly sophisticated. I'm sure it would be doable with JMWE but you might need to get help from a Solution Partner with JMWE Cloud expertise.

You might also want to have a look at JMWE's Event-based actions (to automatically do calculations when a field is modified) and Scheduled Actions (if you want to automate monthly invoices.

Suggest an answer

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

Atlassian Community Events