I am looking to enable simple equation which is being done easily in Excel :
i have around 14 blocks/epics that have the , current set up ,
so if we consider i am selecting drop down in current maturity level as : L2 the equation should be calculate as example ( 11*2/5 = 4.4) and 4.4 should automatically reflect in the current score field.
so if we consider i am selecting drop down in target maturity level as : L3 the equation should be calculate as example ( 11*3/5 = 6.6) and 6.6 should automatically reflect in the target score field.
I have tried many automation rule, none has works as i am facing challenging converting the text field to number so the math would work, anyone can help ?
Last equations i have used and returned with error cannot convert to number :
{{issue."Weight %".toNumber.default(0)}} * {{if(issue."Current Maturity Level".value.equals("L1"), 1, if(issue."Current Maturity Level".value.equals("L2"), 2, if(issue."Current Maturity Level".value.equals("L3"), 3, if(issue."Current Maturity Level".value.equals("L4"), 4, if(issue."Current Maturity Level".value.equals("L5"), 5, 0)))))}} / 5
{{issue."Weight %".toNumber.default(0)}} * {{if(issue."Target Maturity Level".value.equals("L1"), 1, if(issue."Target Maturity Level".value.equals("L2"), 2, if(issue."Target Maturity Level".value.equals("L3"), 3, if(issue."Target Maturity Level".value.equals("L4"), 4, if(issue."Target Maturity Level".value.equals("L5"), 5, 0)))))}} / 5
the following is the Log for the error showing :
Hi @Khalid El-Bialy -- Welcome to the Atlassian Community!
First, what version of Jira are you using: Cloud, Server, or Data Center. That impacts the supported features of automation rules.
Next, I recommend pausing to review the documentation for how math expressions work with smart values: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-math-expressions/
Reading this you will find several things in your expression are not valid syntax.
Finally, as your maturity custom fields' dropdown values contains the number with an "L" character prefix, that could be removed and the result used in the math expression.
Putting that all together, perhaps try this expression, assuming your fields all have values selected and that your smart values are correct:
Current Score:
{{#=}}0{{issue."Weight %"}} * 0{{issue."Current Maturity Level".value.substringAfter("L")}} / 5{{/}}
Target Score:
{{#=}}0{{issue."Weight %"}} * 0{{issue."Target Maturity Level".value.substringAfter("L")}} / 5{{/}}
And, if you need to manage the significant digits, perhaps add the ROUND() function to the expression.
Kind regards,
Bill
@Bill Sheboy thank you for your response, I Am using Jira cloud, it is also team managed where i have no admin privileges, I can only configure some field in my project and all but that's it, i cannot change the filed it self to number or any , actually by applying your rule this is the closest i have had so far, it is now executing the equation and showing the correct result in the log only, however in the "current score" field it is returning "0" but it is still failing, the following is the log :
Could not convert the field value to a number. Please ensure the value is a number, math expression or smart-value that can be converted into a number.
Current Score: Current Score: 4.4
debug: Current Score: 4.4
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For more context, please post images of:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
attached the Epic config field, Rule builder, and log,
BElow is the action added to edit the field current and target score.
Current:
Current Score: {{#=}}0{{issue."Weight %"}} * 0{{issue."Current Maturity Level".value.substringAfter("L")}} / 5{{/}}
Target:
Target Score: {{#=}}0{{issue."Weight %"}} * 0{{issue."Target Maturity Level".value.substringAfter("L")}} / 5{{/}}
Debug:
debug: Current Score: {{#=}}0{{issue."Weight %"}} * 0{{issue."Current Maturity Level".value.substringAfter("L")}} / 5{{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah, you added the prefix text I put on the number calculation. For example, "Current Score: "
When setting the number value in the Edit Work Item action, only include the math expression, such as:
{{#=}}0{{issue."Weight %"}} * 0{{issue."Current Maturity Level".value.substringAfter("L")}} / 5{{/}}
.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for your support, your solution fixed the rule right away, if possible you can help out in this, following the same topic i am trying to create another automation rule to calculate the sum of all current and target score through all my 14 epics
below what i have tried to do , i have created one more Task , and configured new four field
DCX Overall Current score % --> number filed and it should return the current score value from all 14 epics ( DCX-1, DCX-2, ..etc)
DCX Overall target score %--> "number filed "and it should return the target score value from all 14 epics ( DCX-1, DCX-2, ..etc)
DCX Overall current level -->"text field" it should validate the score in the filed above DCX Overall Current score % fails under which level
DCX Overall target level "text field" it should validate the score in the filed above DCX Overall Target score % fails under which level
I have tried to use variable to store the data and just call this variable once more, however that did not work out and i keep getting frailer error to the rule.
(Trigger: when filed changes in any of the 14 DCX epics.
Actions: Find all 14 epics using keys (DCX-1 to DCX-14).
Calculate totals: Total Current Score = sum of all epics’ Current Score
Calculate Total Target Score = sum of all epics’ Target Score.
Update DCX Overall Summary " task" : with field "DCX Overall Current score % = Total Current Score;"
Update DCX Overall Summary " task" : with field DCX Overall target score % = Total Target Score".
update Overall Summary " task": field "DCX Overall current level" with value either (L1,L2,L3,L4,L5) "based on range per each level provided below" and the returned value on the field " DCX Overall Current score %"
update Overall Summary " task" :Field "DCX Overall target level with value either (L1,L2,L3,L4,L5) "based on range per each level provided below" and the returned value on the field " DCX Overall target score % "
1–29 = L1
30–49 = L2
50–69 = L3
70–89 = L4
90–100 = L5
Add a log to audit steps and detect failures.)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
First thing: as your original question was answered, I recommend creating a new question for a new topic. And if the two are related, perhaps including a link to the earlier one. That will help focus the discussion and ensure more people see it to offer help. Thanks!
For your new rule, I observe several things to check...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Welcome to the community.
Try using, issue."Current Maturity Level".value.replace("L1","1")
Or try {{issue.myCustomField.value.asNumber}}
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.
On the edit action ,instead of using the field names, use the customfield_id.
So:
Current Score: {{#=}}0{{issue.customfield_xxxxx}} * 0 {{issue.customfield_xxxxx.value.substringAfter("L")}} / 5{{/}}
Find custom field ID; learn-multiple-methods-to-obtain-custom-field-ids-for-jira-and-jira-service-management-products
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.