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.
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.
that did not work as well
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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.