⟵ hearthere ⟶
  • Training course
  • Creating simple tables and fields
  • Codes base level
  • Selects and links between tables
  • Table settings basic level
  • Prefilters base level
  • Conditional formatting basic level
  • Action codes base level
  • Using pop-up windows
  • Cycles base level
  • Roles and users on the web
  • Codes advanced level
  • Action codes advanced level
  • How can I get the previous value of a field and use it in the action code?
  • Strong action blocking by server conditions
  • At what moment is the data for the action codes taken?
  • Cross-execution of actions
  • Opening a nested temporary table and returning data to the parent table
  • Features of calling linkToInput and linkToButtons from popups
  • Relative list and number changes via set
  • Inserting rows after a certain row when sorting by order field
  • Using listReplace to execute actions
  • Using the panels of other tables
  • How to open the file upload window?
  • Using an arbitrary form in linkToInput
  • How to perform actions on the rows highlighted with checks?
  • Prefilters advanced level
  • Field and table settings advanced level
  • Cycles advanced level
  • Formatting advanced level
  • Select-Tree
  • Executing a scheduled action code
  • Printing and emailing
  • Notifications
  • API interaction
  • Adaptivity and Sections
  • How can I get the previous value of a field and use it in the action code?

    How do the current and previous values behave when adding and removing a row?

    The previous value can be taken from the variable $#onfv and through the reference #old.field_name.

    • When adding a row — the previous value is empty! Because the row did not exist.

    • When deleting a row — the current value is empty! Because the row no longer exists.

    Therefore, if you want to perform an action on the delete trigger and use the value from the field of the deleted row, you need to take the previous value (the one that was before the deletion).

    Code for the delete trigger action:


    =:
    recalculate(table: 'table'; where: 'connect_field' = $#onfv)

    How can I allow an action only when one field value changes from one value to another?

    For example, you have statuses [1,2,3,4] and you need to perform an action only if the status changes from 3 to 4:

    Action code:


    =:
    if(condition: $#onfv = 3; condition: $#nfv = 4; then: $action) action: set(table: 'table'; field: 'field' = "complete"; where: 'num' = $#nci)

    What value should we use if we want to perform an action using the data of the row to be deleted?

    Previous value!


    =:
    recalculate(table: 'table'; where: 'connect_field' = $#onfv)