I'm encountering issues with implementing automation using ScriptRunner in Jira to calculate the end date based on custom estimations and to update epic estimations based on child issues. Below are the details and the scripts I have tried:
Requirements:
- Working Days: 5 working days a week (Monday-Friday)
- Working Hours: Each day has 7 working hours
- Total Working Days: Calculated as
(Dev Estimations + QA Estimations + Tech Art Estimations) / 7, rounded up. - End Date Calculation: Start Date + Total Working Days, excluding weekends.
- Epic Estimations: Update if the total of child issues' estimations exceeds the current epic estimations.


Attempted Approach without ScriptRunner (Using Jira Automation):
- Trigger: Field value changed
- Fields: Start Date, Dev Estimations, QA Estimations, Tech Art Estimations
- Conditions:
- Issue fields condition:
- Field: Start Date
- Condition: is not empty
- Actions:
- Create variable to calculate totalHours:
- Variable name: totalHours
- Value:textCopy code
{{#=}}issue.fields["Dev Estimations"].toNumber() + issue.fields["QA Estimations"].toNumber() + issue.fields["Tech Art Estimations"].toNumber(){{/}}
- Create variable to convert totalHours to totalWorkingDays:
- Variable name: totalWorkingDays
- Value:textCopy code
{{#=}}ceil(totalHours / 7){{/}}
- Create variable to calculate interimEndDate:
- Variable name: interimEndDate
- Value:textCopy code
{{#=}}{{issue.fields["Start Date"].plusDays(totalWorkingDays)}}{{/}}
- Conditions and Actions to Adjust for Weekends:
- Condition: If interimEndDate is Saturday
- Advanced compare condition:
- First value: {{interimEndDate.toDate("e")}}
- Condition: equals
- Second value: 6
- Action: Edit issue fields to set End Date to {{interimEndDate.plusDays(2)}}
- Condition: If interimEndDate is Sunday
- Advanced compare condition:
- First value: {{interimEndDate.toDate("e")}}
- Condition: equals
- Second value: 7
- Action: Edit issue fields to set End Date to {{interimEndDate.plusDays(1)}}
- Default Action: If interimEndDate is not a weekend
- Edit issue fields:
- Field: End Date
- Value: {{interimEndDate}}
Any help to resolve these issues or to identify where the scripts might be failing would be greatly appreciated!
Thank you!