LSPS documentation logo
LSPS Documentation
Table with Derived Values

Required result: A table with a column with a value derived from another column value: One column value is persisted; the derived value is transient. The column values depend on each other and adapt to each other when either is changed.

When you change Interest Rate, the Withdrawal Date changes. Withdrawal Date is not persisted.
  1. Create the underlying data type hierarchy with the base shared record and a non-shared record with fields for the derived values:
    1. Create or import the base shared record.
    2. Create a record with the derived field.
    3. Define an association between the records: the derived record is the target of the relationship.
      Base shared record TimeDeposit associated with the derived non-shared record Withdrawal

      Important: In such scenarios, you cannot use the supertyping mechanism since a shared record is involved:

      • If you used a derived non-shared record that is the supertype of the base shared record, the derived record would include the fields of the base shared record but the shared record itself could not be recovered efficiently.
      • If you used a derived non-shared record that is the supertype of the base shared record, If you decided to define the base shared record as the supertype of the wrapper non-shared record, whenever you decide to refresh the table with the record data, new shared record instances would be created and written in the database.
  2. Create the form definition.

    1. Create a local variable of the derived record type.

      The variable will serve as the iterator variable for the table.

    2. Create a local variable of the collection type with the derived records (for example, List<Withdrawal>), and initialize it so it holds the available Withdrawal object, for example, with the collect() function.
      The collection form variable with the initial value
    3. In the form, insert the Table component and define its properties:
      • Data Kind as Data
      • Data as a closure that returns the local variable with data.
      • Data Iterator as reference to the iterator variable
    4. In the table component, insert Table Column components and input components as their child components: define their ID and the binding of the input components to the respective field of the iteration variable (in the example, &currentWithdrawal.timedeposit.interestRate and &currentWithdrawal.withdrawalDate).
    5. On each input component define the following:
      1. Create ValueChangeListeners: as the component to refresh, define the other input component and as Handle expression, define the new value of the iterator field, for example, using a function. Do not define the column as the component to be refreshed. Columns do not support the refresh action.
        currentWithdrawal.withdrawalDate:= countWithdrawalDate(currentWithdrawal.timedeposit.interest)
      2. Set the Immediate property to true otherwise change of a value will not trigger change of the other value: the change would take place only after another event triggers the processing.

    When set to true, the value changes are processed whenever the user clicks out of the input component or presses Enter.

  3. Create a document or a process with a to-do that uses the form.