Hi team,
We have some automations which are calculating the costs or time of the projects depending on the rate (customfield_10181), actually we have this expressions to calculate it:
To the costs we multiply the hours with the rate and to the opposite we divide it:
Examples:
{{#=}}{{issue.ENE21 Plan H}} * {{issue.customfield_10181}}{{/}}
{{#=}}{{issue.FEB21 Plan H}} * {{issue.customfield_10181}}{{/}}
{{#=}}{{issue.MAR21 Plan H}} * {{issue.customfield_10181}}{{/}}
...
{{#=}}{{issue.ENE21 Plan €}} / {{issue.customfield_10181}}{{/}}
{{#=}}{{issue.FEB21 Plan €}} / {{issue.customfield_10181}}{{/}}
{{#=}}{{issue.MAR21 Plan €}} / {{issue.customfield_10181}}{{/}}
This are working fine but there are showing errors if the users are deleting the values and putting some number field on null, we tried to use some expressions to controlling it but it doen't work fine either, I think it can be something like this:
{{#=}}{{IF(issue.ENE21 Plan H == null, 0, issue.ENE21 Plan H)}} * {{issue.customfield_10181}}{{/}}
{{#=}}{{IF(issue.FEB21 Plan H == null, 0, issue.FEB21 Plan H)}} * {{issue.customfield_10181}}{{/}}
{{#=}}{{IF(issue.MAR21 Plan H == null, 0, issue.MAR21 Plan H)}} * {{issue.customfield_10181}}{{/}}
{{#=}}{{IF(issue.ABR21 Plan H == null, 0, issue.ABR21 Plan H)}} * {{issue.customfield_10181}}{{/}}
...
{{#=}}{{IF(issue.ENE21 Plan € == null, 0, issue.ENE21 Plan €)}} / {{issue.customfield_10181}}{{/}}
{{#=}}{{IF(issue.FEB21 Plan € == null, 0, issue.FEB21 Plan €)}} / {{issue.customfield_10181}}{{/}}
{{#=}}{{IF(issue.MAR21 Plan € == null, 0, issue.MAR21 Plan €)}} / {{issue.customfield_10181}}{{/}}
If someone knows how to solve it, it would be very helpfull to our team.
Thanks in advance,
Mario
You can add default values to your smart values to catch a missing value and stop the expressions breaking. Just add |0 to it. For example:
{{issue.customfield_10181|0}}
Will default to 0 if there is no value.
Hopefully that helps.
Cheers,
Simeon.
Mario,
In fact, if the field is of type number field, leaving the value empty or null will cause automation errors or the final result to appear incorrect.
Instead, try to instruct your users to use the number 0 or 1 and not leave the number field empty.
I think this will be enough to help you.
If this doesn't work or it's not interesting to apply, please let me know. We can try other ways.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Fernando,
thanks for the quick response :)
We already put warning messages in the forms to prevent the users deleting values saying they must put 0 values, but sometimes they don't do it well and delete it anyway.
For prevent that errors we want to control it with some expression.
Also we think when the Scriptrunner Behaviours are able in cloud it could solve this right?
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.