Skip to main content
Version: 6.x

Properties and actions block

The property and action block of the FORM statement adds properties and actions to the form structure.

Syntax

PROPERTIES [(cparam1, ..., cparamN)] [formPropertyOptions] formPropertyDecl1, ..., formPropertyDeclM

Each formPropertyDecl describes the property or action being added to the form structure and has the following syntax:

If the common parameters (cparam1, ..., cparamN) have been specified:

[[alias1] [caption1] =] [ACTION] formPropertyId1 [formPropertyOptions1], ..., [[aliasK] [captionK] =] [ACTION] formPropertyIdK [formPropertyOptionsK] 

If the common parameters of the block have not been specified, then:

[[alias1] [caption1] =] formMappedProperty1 [formPropertyOptions1], ..., [[aliasK] [captionK] =] formMappedPropertyK [formPropertyOptionsK] 

Each formMappedProperty describes the implementation of a property or action being added to the form and having one of the following syntaxes

[ACTION] formPropertyId(param1, ..., paramN1) 
formPropertyExpression

{ formActionOperator }

Each formPropertyOptions specifies options for the property or action being added to the form structure. They can be added one by one in arbitrary order:

changeType
SHOWIF propertyExpression
READONLYIF propertyExpression
BACKGROUND propertyExpression
FOREGROUND propertyExpression
HEADER propertyExpression
FOOTER propertyExpression
COLUMNS [groupid] (groupName1, ..., groupNameM)
viewType
NEWSESSION | NESTEDSESSION
DRAW groupObjectName
BEFORE formPropertyName
AFTER formPropertyName
QUICKFILTER formPropertyName
ON eventType actionId(param1, ..., paramZ) | { actionOperator }
ATTR
EXTID extID
IN propertyGroup

Description

One PROPERTIES block adds properties and actions to the form structure. To add a property (action), specify its ID and the form objects whose values will be passed to this property (action) as arguments. Sometimes it’s convenient to list these form objects for the entire PROPERTIES block. To do this, specify the block of common parameters. In this case, when adding a property (action), you only need to specify its ID, while the common parameters will be passed as arguments.

Each property (action) being added to the form structure must have a unique name within the form. This name may be specified either explicitly or based on the name of the property and the passed parameters, i.e. names of objects separated by commas.

FORM order
OBJECTS o=Order
PROPERTIES(o) d=date, Order.number;

In the given example, the names of the added properties date and Order.number will be d and number(o) respectively.

When adding a property (action) to the form structure, you may specify a set of its options. You may also specify common options for the entire PROPERTIES block. If any of the options are specified for both the entire block and a specific declaration, the option value for the declaration will be used.

In all expressions and context-dependent action operators, you can use the names of the objects already declared on the form as parameters.

Parameters

  • cparam1, ..., cparamN

    List of common parameters of the block. Each parameter is specified with the name of the object on the form. If this list is defined, then adding a property (action) will require that you specify only its ID without parameters. The object name is specified with simple ID.

  • alias

    The name of the property or action being added to the form. Simple ID. If the name is not specified, then the name of the property (action) on the form will be the same as the property's name itself (but without the namespace and signature) with parameters, i.e. names of the objects separated by commas and enclosed in brackets.

  • caption

    The caption of the property or action being added to the form. String literal. If the caption is not specified, then the caption of the property (action) itself will be used on the form.

info

In the current platform implementation, if the name and caption are not specified together, then = is required when using the expressions and action operators (i.e. f(a,b), but =a*b+5)

  • formPropertyId

    ID of the property or action being added to the form structure.

    Alternatively, you may use object operators instead of the property/action IDs:

    • VALUE displays the object value (or the object ID for custom classes).
    • NEW creates a new object.
    • EDIT edits the object.
    • DELETE deletes the object.
    • NEWEDIT creates and edits a new object.

    In addition, you may use brackets to explicitly specify a class whose object will be added/edited (e. g. NEW[A]) for operators NEW, EDIT, and NEWEDIT or for property/action IDs.

  • ACTION

    Keyword. When specified, it is considered that the action is specified in formPropertyId. When not specified, it is initially considered that a property is specified in formPropertyId; otherwise, if property is not found, it is considered that an action is specified in formPropertyId.

  • param1, ..., paramNk

    List of parameters of the added properties or actions. Each parameter is specified with the name of the object on the form. The number of specified parameters must match the number of parameters for the property or action being added. Not specified if the common parameters block is specified. The object name, in turn, is specified with a simple ID.

  • formPropertyExpression

    Expression being added to the form structure.

  • formActionOperator

    Context-dependent action operator being added to the form structure.

Options for the property or action

  • changeType

    Specifying standard handlers for property/action change events. It is specified with one of the keywords:

    • CHANGEABLE calls the corresponding handler of the triggered event. Default value. It makes sense to use it explicitly only when another modifier is defined for the entire block but should not be applied to a specific property.
    • READONLY will either turn on the filtering mechanism or simply ignore the event when the user tries to change the property.
    • DISABLE The property is not available for changing.
    • SELECTOR shows a dialog for changing the current value of the object (not the property value) when the user tries to change the property. Applicable only for properties with one parameter.
  • SHOWIF propertyExpression

    Specifies a property that determines visibility of the property or action being added to the form. If the value of this property is NULL, then the property (action) being added will not be displayed. Cannot be used together with the HEADER option.

  • READONLYIF propertyExpression

    Specifies a property that allows or prohibits changing the property being added (or execution of the action being added). If the value of this property is NULL, then the property being added will not be changeable, and the action being added will not be executable. The behavior is similar to the READONLY option, but with an additional data-dependant condition.

  • BACKGROUND propertyExpression

    Specifying a property that determines the background color for the value cell of the property (action) being added. The property may have the COLOR type (in this case, its value will be used) or any other type. In this case, if the value is not equal NULL, then either the default color stored in the global property System.defaultBackgroundColor (set in settings) or yellow color (if the default color is not set) will be used.

  • FOREGROUND propertyExpression

    Specifying a property that determines the text color for the value cell of the property (action) being added. The property may have the COLOR type (in this case, its value will be used) or any other type. In this case, if the value is not equal to NULL, then either the default text color stored in the global property System.defaultForegroundColor (set in settings) or red color (if the default color is not set) will be used.

  • HEADER propertyExpression

    Specifying a property that determines the header for the column of the property (action) being added. The return value of this property will be used as the header. If the return value is NULL, then the added property (action) will be automatically hidden.

    • propertyExpression

    Expression.

  • FOOTER propertyExpression

    Specifying a property that determines the footer of the property (action) being added. Used only in the print view of the form.

  • COLUMNS [groupid] (groupName1, ..., groupNameM)

    Specifies the upper object groups whose values will define a set of columns to display the added property (action). The COLUMNS option is often used with the HEADER option which defines headers for these columns.

    • groupid

      Column group ID. String literal. If the COLUMNS option is specified for several properties (actions) being added with the same set of object groups, then by default the columns of the first property (action) will be added, followed by the columns of the second property (action), and so on. To group columns of different properties (actions) by values of the upper objects, you can set for them the same string ID of the group of columns. In this case, the columns for different properties (actions) will alternate.

    • groupName1, ..., groupNameM

      List of the names of the upper object groups. Each name is defined by a simple ID.

  • DRAW groupObjectName

    Specifying the name of the object group on the form where the added property or action will be displayed in the table of the specified object group.

    • groupObjectName

      Name of an object group. Simple ID.

  • viewType

    Specifying the view type of the property or action being added:

    • GRID — table column
    • TOOLBAR — toolbar
    • PANEL — panel

    If not specified, the corresponding option from the property options is used. If it is also not specified, then the default view type is used for the display group of this property or action.

  • NEWSESSION | NESTEDSESSION

    Modifiers specifying that object operators (NEW, EDIT, DELETE, NEWEDIT) must be executed in a new (nested) session.

  • BEFORE formPropertyName | AFTER formPropertyName

    Specifying that a property or an action should be added to the form structure before (keyword BEFORE) or after (keyword AFTER) the previously added property or action. Typically used in the form extension concept.

  • QUICKFILTER formPropertyName

    Specifying the property to be used in default handlers for quick filtering.

  • ON eventType actionId(param1, ..., paramZ) | { actionOperator }

    Specifying the action that will be executed when the specified form event occurs.

    • eventType

      Type of form event. It is specified by one of the following keywords:

      • CHANGE — the user tries to change the value of the property being added (call the added action).

      • CHANGEWYS — the user tries to change the displayed value of the property. It is triggered when the user inserts a text into the added property (by pressing Ctrl + V or similarly).

      • GROUPCHANGE — the user tries to change the property value for all objects in the table (group change).

      • EDIT — the user tries to edit the object that represents the property value.

      • CONTEXTMENU [caption] is the event type which adds a menu item executing the specified action to the context menu of the property (action) on the form. You can also specify the caption for this menu item (as string literal). If it is not specified, then, by default, it will be the same as the action caption.

        • caption

          Caption of the item in the context menu. String literal. If the caption is not specified explicitly, then it will be the same as the caption of the action called upon the event.

    • actionId

      Action ID.

    • param1, ..., paramZ

      List of action parameters. Each parameter is specified with the object name on the form. The object name, in turn, is specified with a simple ID.

    • actionOperator

      Context-dependent action operator.

  • ATTR

    Keyword. Used only in the hierarchical view. Indicates that:

    • When importing from XML, the data is imported from the tag attributes instead of the child tag.
    • When exporting to XML, the data is exported to the tag attributes instead of the child tag.
  • EXTID extID

    Specifying the name to be used for export/import operations of this property. Used only in the structured view.

    • extId

      String literal.

  • EXTNULL

    Keyword. Used only in the hierarchical view. Indicates that when exporting to XML / JSON, NULL value will not be skipped, will be exported:

    • to JSON as 'null'.
    • to XML as empty value.
  • IN propertyGroup

    Specifying a property/action group which the property (action) on the form belongs to. If this option is not specified, then the property group of the property itself will be used as the property (action) group on the form.

Examples

CLASS Order;
date = DATA DATE (Order);
time = DATA TIME (Order);
number = DATA INTEGER (Order);
series = DATA BPSTRING[2] (Order);

note = DATA ISTRING[255] (Order);

CLASS OrderDetail;
order = DATA Order (OrderDetail) NONULL DELETE;
date(OrderDetail d) = date(order(d));

index (OrderDetail d) = PARTITION SUM 1 ORDER d BY order(d) CHARWIDTH 4;

sku = DATA Sku (OrderDetail);
nameSku (OrderDetail d) = name(sku(d));

quantity = DATA NUMERIC[10,2] (OrderDetail);
price = DATA NUMERIC[10,2] (OrderDetail);
sum = DATA NUMERIC[12,2] (OrderDetail);

sum (Order o) = GROUP SUM sum(OrderDetail d) BY order(d);

quantity (Order o, Sku s) = GROUP SUM quantity(OrderDetail d) BY order(d), sku(d);
lastDetail (Order o, Sku s) = GROUP MAX OrderDetail d BY order(d), sku(d);
changeQuantity (Order o, Sku s) {
INPUT n = NUMERIC[10,2] DO {
IF lastDetail(o, s) THEN {
IF n THEN
quantity(OrderDetail d) <- n WHERE d == lastDetail(o, s);
ELSE
DELETE OrderDetail d WHERE d == lastDetail(o, s);
} ELSE IF n THEN {
NEW d = OrderDetail {
order(d) <- o;
sku(d) <- s;
quantity(d) <- n;
}
}
}
}

stopOrder = DATA BOOLEAN (Sku);
onStock = DATA NUMERIC[10,2] (Sku);
ordered = DATA NUMERIC[10,2] (Sku);

CLASS Customer;
name = DATA ISTRING[100] (Customer);
FORM customers
OBJECTS c = Customer
PROPERTIES(c) READONLY name
LIST Customer OBJECT c
;

customer = DATA Customer (Order);
nameCustomer (Order o) = name(customer(o));

customer(OrderDetail d) = customer(order(d));

CLASS Region;
name = DATA STRING[100] (Region);

region = DATA Region (Customer);

// declaring the orders form
FORM order 'Order'
OBJECTS o = Order PANEL // adding an order object to the form
PROPERTIES VALUE(o), // adding the order ID in the database
// adding properties date/time of order, series/order number
date(o), time(o), series(o), number(o),
// adding the name of the customer, which by default will be available for editing
// here, when the user tries to edit it, a dialog will be called for the customer choice -
// a form for which the LIST customer parameter is set
nameCustomer(o),
note(o), // adding a note
// adding the order amount without the possibility of editing, since it is automatically
// calculated based on the sum of rows
sum(o) READONLY

OBJECTS d = OrderDetail // adding the order line object
PROPERTIES(d) // all properties in this block will have an order line input
index READONLY, // adding the ordinal line number and making it impossible to edit
nameSku, // adding a name
quantity, price, sum, // adding quantity, price, amount
NEW, // adding the predefined NEW action that adds a new order line
DELETE // adding an action that will delete the order line
FILTERS order(d) == o // indicating that only lines related to this order should be shown

// adding a sku object to which the totals for each sku in the order will be written
OBJECTS s = Sku
// adding a name, while making a note that it cannot be edited on this form
PROPERTIES(s) name READONLY

// adding a property that will display the ordered quantity by sku in this order
PROPERTIES quantity(o, s)
// by default, even though the property is not marked READONLY and nothing will happen when the user
// tries to change it, since quantity is an aggregated property. In this case, a note is made that
// when the user tries to change, the changeQuantity action will be called. An algorithm is written
// in this property that will create/delete order lines or change the quantity in them
ON CHANGE changeQuantity(o, s)
// making the property unavailable for editing, if the order is prohibited for this sku
READONLYIF stopOrder(s)
// in addition, in this case, this cell is highlighted with custom background so that the user
// can see such positions in advance
BACKGROUND stopOrder(s)

EDIT Order OBJECT o // marking the form as a form for editing orders
;

EXTEND FORM order // expanding the form with the Mixin concept
// adding the property of the current balance to the form before the quantity in the order
PROPERTIES onStock(s) BEFORE quantity(d),
// adding to the form the quantity of already ordered products within all orders
ordered(s) BEFORE quantity(d)
;

FORM orders 'Orders'
OBJECTS o = Order
// all properties in this block are unavailable for editing
PROPERTIES(o) READONLY VALUE, date, number
// adding predefined NEW and EDIT actions that will call the order form to add orders
PROPERTIES(o) NEWSESSION NEW, EDIT, DELETE
;

// creating a "report" in which orders for a certain interval will be visible in the context of customers
// in a particular region
FORM orderReport 'Sales by warehouse'
// declaring a group of objects, consisting of 2 objects of the Date class with the appropriate captions,
// which will always be displayed as a panel
OBJECTS interval = (dateFrom 'Date (from)' = DATE, dateTo 'Date (to)' = DATE) PANEL
// adding to the form the properties of the date objects values, with which the user can select dates
// in addition, assigning to these properties on the form names dateFrom and dateTo, respectively
PROPERTIES dateFrom = VALUE(dateFrom), dateTo = VALUE(dateTo)

OBJECTS r = Region PANEL // adding a region object, by which customers will be filtered
// adding the property region name, at the same time marking that when editing it, the dialog for choosing
// a region should be called, the selected value of which will be used as the current value
PROPERTIES(r) name SELECTOR

// adding the customers object, specifically not adding a single property so that it is "invisible",
// but it is needed in order to display customers in columns
OBJECTS c = Customer

FILTERS region(c) == r // setting a filter so that customers are only from this region

// adding a sku object, in the table of which basic information will be displayed
OBJECTS s = Sku
// adding the sku name and making it READONLY, otherwise the user will be able to change the product names
// directly in the report
PROPERTIES(s) name READONLY

// adding a property in which the quantity of ordered sku by customers for a certain date interval is calculated
PROPERTIES =
[GROUP SUM quantity(OrderDetail d) IF date(d) >= dateFrom AND date(d) <= dateTo BY sku(d), customer(d)](s, c)
COLUMNS (c) // marking that customers should be displayed in columns, with the same number of columns
// as there will be rows in the customer object, taking into account filters, and they will be
// displayed in the same order
HEADER name(c) // setting that the name of the customer will be used as the column heading
;