Objective: I have an existing rule that produces a decimal proportion, BUT I need it to produce the percentage and round it to the nearest whole number. This is my current rule:
Attempts:
I tried changing the smart value to this {{issue.OrigAllowed.format(".##")}} just to round it but it did not work. So I did not even attempt to covering it to a percentage. Which I don't know if I can even do that or would that have to be a separate rule?
Hi @Mireya Cintora, if I understand your question correctly you might try something like shown in this formula:
Which gives this result:
So, for your rule you need to apply smart values for your custom fields into the ROUND() function, and further define the correct percentage formula. Something like this might work:
{{#=}}ROUND({{customfield_10455}} / {{customfield_10421}} * 100,0){{/}}
The zero marked in yellow below indicates the precission, i.e. how many decimals to apply to the result.
You don't need to create a varibale for this, apply to your code directly into the And: Edit issue fields step and set "Original Allowed".
The ROUND() functioin is described on this page Jira smart values - math expressions | Automation for Jira Cloud and Data Center | Atlassian Documentation.
TimK
Oh my goodness thank you! It worked perfectly, last question how can i then make it produce the % symbol?
If anyone else is wondering this is what the automation looks like:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Mireya Cintora, great it worked for you. And thanks for accepting the answer.
To add the % at the end, try something like this:
Which will give this result
TimK
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Unfortunately it did not work. I think based off the audit log its because the field is a number field and the percentage symbol is not a number?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Mireya Cintora, yes that is right. You cannot add any non-numbers to a number field. You might add something in the description for the field, that informs about the result in percentage.
You might use a text field for this instead of number field even if it contains a number value. Though this is not working prefect if you need to sort by this field in reports etc. A text field uses text sort therefore it regards 10 as before 2. In number sort 2 is before 10 etc.
TimK
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.