Hi,
I've created a jira automation that creates a table in the description field based on custom fields I added to the form, and I'm also calculating the sum of all items i.e if I have an order for 10 devices it will calculate each device type unit * price per table row and in the bottom of the table will post the total of all devices:
Here is the automation rule:
||*Needed Device*||*Quantity*||*Cost Summary*|| |{{issue.Needed Mobile Device New}}|
{{issue.Quantity New}}|{{#=}}{{issue.Needed Mobile Device New.getValue().substringAfter("$").remove(",")}} * {{issue.Quantity New}}{{/}}| |
{{issue.Needed Mobile Device New 2}}|{{issue.Quantity New 2}}|{{#=}}{{issue.Needed Mobile Device New 2.getValue().substringAfter("$").remove(",")}} * {{issue.Quantity New 2}}{{/}}|
|{{issue.Needed Mobile Device New 3}}|{{issue.Quantity New 3}}|{{#=}}{{issue.Needed Mobile Device New 3.getValue().substringAfter("$").remove(",")}} * {{issue.Quantity New 3}}{{/}}|
|{{issue.Needed Mobile Device New 4}}|{{issue.Quantity New 4}}|{{#=}}{{issue.Needed Mobile Device New 4.getValue().substringAfter("$").remove(",")}} * {{issue.Quantity New 4}}{{/}}|
|{{issue.Needed Mobile Device New 5}}|{{issue.Quantity New 5}}|{{#=}}{{issue.Needed Mobile Device New 5.getValue().substringAfter("$").remove(",")}} * {{issue.Quantity New 5}}{{/}}|
|{{issue.Needed Mobile Device New 6}}|{{issue.Quantity New 6}}|{{#=}}{{issue.Needed Mobile Device New 6.getValue().substringAfter("$").remove(",")}} * {{issue.Quantity New 6}}{{/}}|
|{{issue.Needed Mobile Device New 7}}|{{issue.Quantity New 7}}|{{#=}}{{issue.Needed Mobile Device New 7.getValue().substringAfter("$").remove(",")}} * {{issue.Quantity New 7}}{{/}}|
|{{issue.Needed Mobile Device New 8}}|{{issue.Quantity New 8}}|{{#=}}{{issue.Needed Mobile Device New 8.getValue().substringAfter("$").remove(",")}} * {{issue.Quantity New 8}}{{/}}|
|{{issue.Needed Mobile Device New 9}}|{{issue.Quantity New 9}}|{{#=}}{{issue.Needed Mobile Device New 9.getValue().substringAfter("$").remove(",")}} * {{issue.Quantity New 9}}{{/}}|
|{{issue.Needed Mobile Device New 10}}|{{issue.Quantity New 10}}|{{#=}}{{issue.Needed Mobile Device New 10.getValue().substringAfter("$").remove(",")}} * {{issue.Quantity New 10}}{{/}}|
Total = ${{#=}}({{issue.Needed Mobile Device New 2.getValue().substringAfter("$")}} * {{issue.Quantity New 2}}) + ({{issue.Needed Mobile Device New 2.getValue().substringAfter("$").remove(",")}} * {{issue.Quantity New 2}}) + ({{issue.Needed Mobile Device New 3.getValue().substringAfter("$").remove(",")}} * {{issue.Quantity New 3}}) + ({{issue.Needed Mobile Device New 4.getValue().substringAfter("$").remove(",")}} * {{issue.Quantity New 4}}) + ({{issue.Needed Mobile Device New 5.getValue().substringAfter("$").remove(",")}} * {{issue.Quantity New 5}}) + ({{issue.Needed Mobile Device New 6.getValue().substringAfter("$").remove(",")}} * {{issue.Quantity New 6}}) + ({{issue.Needed Mobile Device New 7.getValue().substringAfter("$").remove(",")}} * {{issue.Quantity New 7}}) + ({{issue.Needed Mobile Device New 8.getValue().substringAfter("$").remove(",")}} * {{issue.Quantity New 8}}) + ({{issue.Needed Mobile Device New 9.getValue().substringAfter("$").remove(",")}} * {{issue.Quantity New 9}}) + ({{issue.Needed Mobile Device New 10.getValue().substringAfter("$").remove(",")}} * {{issue.Quantity New 10}}){{/}}
Problem is that this handles full 10 fields per each device, so if for example I'm only ordering one or two devices I get an error for the '*' operand that the automation can't resolve it, any suggestions on how to solve it without creating massive if blocks per each situation?
Hi @Ron Aisen
What do you want to do when a quantity value is 0 or empty:
Kind regards,
Bill
I am unclear how to mix those options as they seem mutually exclusive...
To prevent display of a row with a 0 quantity, wrap each row with a conditional, smart value expression to test for a 0 or empty quantity: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-conditional-logic/
To display all rows, with 0 when relevant, use either 0 prefix value or default value, as @Manon Soubies-Camy described. Please note well: that syntax does not work for all possible field types, and I recommend testing to confirm for your fields.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ron Aisen,
You can use | to provide automation rules with default values if your field is empty, for example:
{{#=}}{{issue.story points|1}} * 5{{/}}
If the Story points field is empty, then it'll be replaced with value 1.
Hope this helps!
- Manon
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Manon, it didn't answer my need but I appreciate the help
I ended up doing if blocks saddly but it works so that's what counts
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.