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

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

Sally Wheeler July 14, 2022

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
David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 14, 2022

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
Sally Wheeler July 14, 2022

Thank you. @David Fischer  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?

Sally Wheeler July 14, 2022

@David Fischer  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. 

Sally Wheeler July 14, 2022

image.png

 

I would like this to run on "Incoming Shipment"

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 14, 2022

@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.

Sally Wheeler July 15, 2022

@David Fischer 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?

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 15, 2022

Did you try again after my last comment?

Sally Wheeler July 15, 2022

Oh!! It works! Thank you!! @David Fischer 

Sally Wheeler July 15, 2022

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 

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 15, 2022

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}}
Sally Wheeler July 15, 2022

Hi @David Fischer 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.

   

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 15, 2022

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
AUG Leaders

Atlassian Community Events