CalcAllSave

You can use the CalcAllSave function to execute a comprehensive calculation function against a formula and all its subformulas. The formula hierarchy is saved automatically.

When to use

You can use this function:

  • To recalculate and save an entire formula hierarchy in a single operation
  • After modifying ingredients or components that affect multiple levels of subformulas.

When not to use

You cannot use this function if:

  • You need to preview calculation results before making any changes.
  • You need granular control on a specific subformula to calculate or save.
  • You cannot modify subformulas, all the formulas need to be updated.
  • The changes must not be persisted.

Syntax

int CalcAllSave([Optional, DefaultParameterValue(null)] ref string formulaCode)

Parameters

Parameter Type Required Description
formulaCode string (ref) Optional The formula key (identifier) on which the calculation function is to be executed. Passed by reference.
Note:  If null or omitted, the parameter operates on the current formula in workflow context.

Return Value

The application returns a value zero (0) if the operation is successful.

Impact

  • The function saves all modified formulas and subformulas to the database.
  • The changes are made and displayed to all users after execution.

Prerequisites

  • The subformulas where the user cannot modify, consistent with manual "Calc All/Save All" tree functionality.
  • The subformulas without user modification permission will be skipped.

Example

Example 1
Calculates and saves the formula "DOUGH\0001" and all its subformulas.
CalcAllSave("DOUGH\0001");