Recalculating

The calculated field will automatically recalculate when the row is created or if any dependent fields change. As mentioned in the previous section, even dependents that are referenced through linked records will also have their changes automatically reflected in the calculated field.

However, sometimes you may add a calculated field after data has been added to the list. If you do this, the value of the calculated field for the existing rows will be empty.

You can remedy this quite easily by forcing WorkflowFirst to recalculate the field for all of the existing rows. To do this you need to write a little bit of DbfScript.

First, go to the list that contains the existing records with the new calculation in your application. Keep in mind the name of one of the fields that is used in the calculation.

Then login as administrator and click Admin Tools at the top of the webpage. This will bring up a page with a large area for entering in ad-hoc scripts.

Note : You will need to be logged-in using an administrator account to access the admin tools. 

In the left-side script window, enter a script such as this:

loop through load(&path) as #record
set #record/DependentField = #record/DependentField
save #record
end loop

Replace DependentField with the name of the field that the calculation depends on.

This script runs through all of the rows in the list and saves a pretend change to a field that will trigger the calculation to run.

Note : If you have a significant number of rows, this script may need more time to run or otherwise the system will say it's taking too long. Just insert a more time statement at the start of the script to have the system give the script more time to run. It may be a pain to have to do this, but it's useful because it stops your scripts from getting stuck in an infinite loop.


Next Topic:
v4.2.0.956 (beta)
Up Since 2/29/2024 12:02:23 AM