Content
View differences
Updated by Attila Dombi 7 months ago
All places to recalculate values use same pattern with difference only in using `available_custom_fields` vs `all_available_custom_fields` and which `cf_ids` are used, so better to come up with one call to do it all:
```ruby
affected_cfs = project.available_custom_fields.affected_calculated_fields(cf_ids)
project.calculate_custom_fields(affected_cfs)
project.save if project.changed_for_autosave?
```
<br>
`CustomValue` automatically connects to a project on create if its value is not blank or default (`activate_custom_field_in_customized_project`), it would be better to move this behaviour to a service.
<br>
<mention class="mention" data-id="68618" data-type="work_package" data-text="##68618">##68618</mention>
<br>
Recheck the conditions in the `handle_calculation_errors!` method.
```ruby
affected_cfs = project.available_custom_fields.affected_calculated_fields(cf_ids)
project.calculate_custom_fields(affected_cfs)
project.save if project.changed_for_autosave?
```
<br>
`CustomValue` automatically connects to a project on create if its value is not blank or default (`activate_custom_field_in_customized_project`), it would be better to move this behaviour to a service.
<mention class="mention" data-id="68618" data-type="work_package" data-text="##68618">##68618</mention>
<br>
Recheck the conditions in the `handle_calculation_errors!` method.