Is it possible with math expressions to have a result of always 2 digits?
f.e.
{{#=}}1+2{{/}} = 03 instead of just 3
{{#=}}1+10{{/}} = 11
I was trying to do a check with IF(condition,value_if_true,value_if_false) to place a "0" in front of the result when it's <10 but that didn't work out...
Hi Bill;
The outcome of the math should be in the summary-field, so a text field. I can f.e. fetch the week number by adding xxxxxxx.format("ww"). But whenever i'm calculating someting like f.e. {{#=}}1+2{{/}}, then the result is always 3 and not 03 :)
Hi @ray
Are you asking about text fields (or output) or number fields? I text fields, that is possible, but it is not possible to store a number field as the leading digits would drop when saved.
Let's assume your output is either a text field or output to the log, email, or a text field...
I believe if you use the inline math operations instead, you could add the format() function on the end to get that result.
{{someField.plus(someNumber).format("000")}} -- this would prefix 3 digits with leading zeros
However if you are using numbers without any field references, you would do this in three steps:
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ray, please try to stick to one thread when responding. That will help others in the future know if there are multiple answers to a question. Thanks!
Would you please explain what problem you are trying to solve?
I suggested a method to format numbers stored in fields/smart values as text with left-padding. However if you have a known, literal expression like {{#=}}1+2{{/} why wouldn't you just replace that with "03" instead of doing the math?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok :)
To respond to your question: because the summary is based on several calculations to number the task based on week numbers. But not only weeknumber, because weeknumber only could be formatted with xxxxx.format("ww"). But whenever I try to f.e. add +1 to the resulted weeknumber, the formatting will not by 2 digits, but only when when it's below 10.
This is my calculation:
{{triggerIssue.customfield_13403.format("ww")}}-FLOOR({{triggerIssue.customfield_13403.format("ww")}}/2){{/}}
the result should be f.e. 03 instead of 3 when it's below 10. I could hard code a "0" as prefix, but that's a manual solution
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That is different than what you described, as you are in fact using issue fields. Because of that you can write that as a single expression, using the inline, math operations.
{{triggerIssue.customfield_13403.format("ww").minus(triggerIssue.customfield_13403.format("ww").divide(2).floor).format("00")}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Bill Sheboy
thanks for the advice I tried your code but I couldn't get any result by using inline math. I also tried these to find out the errors:
1. {{now.format("yyyy")}}
2. {{now.format("yyyy").divide(2)}}
3. {{now.format("yyyy").divide(2).format("0000")}}
only 1. gave me the result of 2023. The other 2 didn't give me any result
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
My mistake: I left off the conversion back to numbers after use of format() as that function leads to a text value.
Please try this:
{{triggerIssue.customfield_13403.format("ww").asNumber.minus(triggerIssue.customfield_13403.format("ww").asNumber.divide(2).floor).format("00")}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Bill Sheboy
Still no luck :(
I replaced the customfields with now, just to make sure that the error isn't in the customfields. I even tried to leave out the calculations to try to debug it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Would you please post images of your complete rule, the details of the action where you are using that expression, and of the audit log details showing the rule execution? Those may provide some context for what is happening. Thanks!
Until we see those...if you look at that error message it shows there is a missing right parenthesis for the minus() function call.
As a tip: the automation rule editor does not help with matching up curly-brackets, parentheses, etc. It can help to write your expressions in a different text editor, and then to copy/paste them into your rule.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Bill Sheboy
There's not much in it actually since I created a test automation to test the expressions. The audit logs states succesfull but in reality the expressions are ignored resulting in blank input
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am using Jira Cloud, I repeated your exact rule write to the comment and it worked for me...again.
Rules can get "glitched" with too many edits; I have no idea why this is, and...
We can check if that is the cause by trying this:
At that point, I'd recommend working with your site admin to contact Atlassian Support. They may see something we are missing, or perhaps can explain if there is a difference for Server versus Cloud in the format() function.
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.