The problem here is that you’ve got a cyclical definition. The gross_year_to_date
field depends on component amounts for its value, and one of your components depends on gross_year_to_date
. Both have to be defined first.
It is logically possible to use gross_year_to_date
in a deduction without having a cyclical definition, but there’s still a sequencing problem. In the Salary Slip’s validate method, components are calculated before the gross_year_to_date
field is. Likewise, when your formula is getting run for the first time, gross_year_to_date
is still zero. When you run it a second time (while submitting), it suddenly has a value.
If you need gross_year_to_date
in a deduction component, you’ll likely need to run validate
a second time before submitting. You could automate this with a server script or simply save the document an additional time. This should get the year to date fields populated, at which point they should work in your formulas.