I have a very simple automation that updates custom fields "target start" and "target end" (custom fields 10040/10041) if a task's sprint field changes.


The automation should update these target start/end dates to the start/end date of the sprint.
Most of the time this automation works as expected. However sometimes I notice that instead of updating the start/end dates to the new sprint, it instead updates to the previous sprint before the change.
So if the task originally had Sprint 1 (and has sprint 1's start/end dates), changing to sprint 2 will trigger the automation, but it will use sprint 1's start/end dates resulting in no date change. Then if I change to sprint 3, the automation will trigger again but populate the start/end dates with sprint 2's start/end dates.
I would have expected that the value of {{issue.Sprint}} should be the new sprint value that has been entered (and triggered the automation) not the original sprint value. But this does not seem to be guaranteed (sometimes it is, but sometimes it's not).
How can I guarantee that issue.X is always the new value of the field?