Automation rule| Update the customfield in percentage based on a calculation performed on 2 different custom fields through a math expression when the field value is changed.
Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.
Summary
Update the field in percentage based on a calculation performed on 2 different custom fields through a math expression when the field value is changed.
- For instance, (customfield_1/100)* customfield_2= customfield_3 value in %
- Example such as customfield_1 has a value 3 and customfield_2 has a value 4 , then customfield_3 value should be 12 not the value .12
Environment
Jira cloud
Solution
Here is the suggestion for automation rule setup:
Trigger: Edit issue field
- (any value changed either from customfield_1 or customfield_2)
Then Log action:
Add value to the audit log.
{{#=}} {{issue.customfield_1}} / 100 * {{issue.customfield_2}} {{/}}
Edit issue for Customfield_3
{{#=}} {{issue.customfield_1}} / 100 * {{issue.customfield_2}} {{/}}
Add Re-fetch data twice
- (so that it will fetch the latest data from the DB which should make the automation be more aware about the changes happening between them is in milliseconds)
Then Log action:
Add value to the audit log.
{{issue.customfield_3.asPercentage("en_IN")}}
As we do not have custom field in % custom field type, therefore added a math expression
And Create variable
- Variable name: {{test}}
Smart value : {{issue.customfield_3.asPercentage("en_IN").remove("%").asNumber}}
- We need to remove % to number as it 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.
- We need to remove % to number as it 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.
Edit issue for Customfield_3
- {{test}}
Here is the automation rule snippet: