Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×Hi,
We need to show the message to the user at the transition in the task. The message should display the sum of the calculated field from each subtask. Also, if in one of the subtasks the field value is zero, then instead of the sum show, for example, the value "?".
Any ideas?
Hi Helen,
If I understand you correctly, as the user transitions the card from one status to the other, you want to show the user the value of the custom field. Correct?
If so, you could place a transition screen on the transition that displays the value of the field and place a condition on the transition where the custom field is > 0.
Then create another transition to the same status with a condition where the custom field 0 or is empty. There would be no screen attached to this transition.
Does that sound like what you are trying to accomplish?
Hi John,
As the user transitions the card from one status to the other, we want to show the user sum the values of the custom field from the subtasks.
Is it possible to calculate the sum of the values of fields of type Calculated (scripted) Number Field in a sil script to show a message to the user?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You would have to update the calculated field as soon as one of the values is updated. Then when you call the transition screen, it's simply displaying the value in the field, not calculating it on the fly.
I don't have ScriptRunner or Server, but I assume you could use it to calculate the value.
I would use Automation For Jira for my Cloud version.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think there can be two options for solving the problem.
The first option is to use the sil-script to calculate the sum of the field values from the subtasks. Then on the transition show a message in which the received sum of values will be indicated.
The second option is to create a field with the type Calculated (scripted) Number Field, and configure it so that the sum of the field values is calculated in it. And, as you suggested, on the transition make a screen with this field.
But the problem is that for the first option it is not possible to calculate the sum of the field values. Perhaps because the field type is "Calculated (scripted) Number Field". Here we would like to know from those who worked with these fields and faced similar problems.
And in the second option, we need to use GroovyScript. I am not good at Groovy scripts.
I executed the following script:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.CustomField
issue.getSubTaskObjects().size()
CustomField total = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Total labor")
double totalSum = 0;
for(Issue subtask: issue.getSubTaskObjects()){
if(subtask.getCustomFieldValue(total) != null)
totalSum += subtask.getCustomFieldValue(total)
}
return totalSum
The script is working. But I do not know how to add a condition:
if in one of the subtasks the field value is zero, then instead of the sum show, for example, the value "?".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think there can be two options for solving the problem.
The first option is to use the sil-script to calculate the sum of the field values from the subtasks. Then on the transition show a message in which the received sum of values will be indicated.
The second option is to create a field with the type Calculated (scripted) Number Field, and configure it so that the sum of the field values is calculated in it. And, as you suggested, on the transition make a screen with this field.
But the problem is that for the first option it is not possible to calculate the sum of the field values. Perhaps because the field type is "Calculated (scripted) Number Field". Here we would like to know from those who worked with these fields and faced similar problems.
And in the second option, we need to use GroovyScript. I am not good at Groovy scripts.
I used the following script:
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.fields.CustomField //return number subtasks issue.getSubTaskObjects().size() CustomField total = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Total") double totalSum = 0; for(Issue subtask: issue.getSubTaskObjects()){ if(subtask.getCustomFieldValue(total) != null) totalSum += subtask.getCustomFieldValue(total) } return totalSum
The script is working. But I do not know how to add a condition:
if in one of the subtasks the field value is zero, then instead of the sum show, for example, the value "?".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, but I am not a Groovy expert either. That's why we switched to Automation for Jira. :-)
Nor have I used those types of fields. I just use a standard Number field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I would start by contacting support for the vendor.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register Now
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.