OBJECT SET DATA SOURCE FORMULA
OBJECT SET DATA SOURCE FORMULA ( {* ;} object ; formula )
Parámetros | Tipo | Descripción | |
---|---|---|---|
* | Operador | → | If specified, object is an object name (string) If omitted, object is a field or variable |
object | any | → | Object name (if * is specified) or Field or variable (if * is omitted) |
formula | 4D.Formula | → | Formula to assign as the data source |
Descripción
The OBJECT SET DATA SOURCE FORMULA command assigns a formula (expression) as the data source of the object(s) designated by the object and * parameters . The formula must be provided as a 4D.Formula
object.
Passing the optional * parameter indicates that the object parameter is an object name (string). If you do not pass this parameter, it indicates that the object parameter is a field or variable. In this case, you pass a field or variable reference instead of a string (field or variable object only).
The formula acts as the source from which the object retrieves its value at runtime. This allows for dynamic behavior, such as calculated values, conditional display, or derived data.
If Null is passed as the formula parameter, 4D will reset the object’s data source to a dynamic form variable.
If the command is applied to an object that does not exist or cannot support formulas, it does nothing.
- The formula is executed in the context of the form that owns the object. When working with nested forms (e.g., subforms), ensure that the formula is defined and assigned in the appropriate form context to avoid unexpected behavior.
- If you assign a formula to an input object or any object with a modifiable value, make sure that the formula is assignable.
Ejemplo
You want to dynamically bind an input to an expression. For example, show the discounted price based on a base price and a discount value:
Form.basePrice := 100
Form.discount := 0.2
$discountedFormula := Formula(Form.basePrice * (1 - Form.discount))
OBJECT SET DATA SOURCE FORMULA(*;"DiscountedPriceInput"; $discountedFormula)
Ver también
OBJECT Get data source formula
LISTBOX SET COLUMN FORMULA
OBJECT SET DATA SOURCE
OBJECT SET VALUE
Propiedades
Número de comando | 1851 |
Hilo seguro | ✗ |