Question
There is a temporary table that displays certain rows depending on the header values. A button is added to the row, which can pass the current header values and row values to create a new cycle. What button code can be used to initialize the creation of a cycle with the transfer of parameters to a new cycle from the current table?
Answer
A loop is created through insert
into the cycles table, recording the id of the added row into a variable (the inserts
parameter of the insert
function).
In the same code, the next action is to perform a set
using the data from the inserts
variable in the cycle
parameter:
a1= : insert(table: 'cycles'; inserts: "inserts"; log: true)
a2=: set(table: 'table_in_cycle'; cycle: $#inserts[0]; field: 'h_field_a' = #h_field_a; field: 'h_field_b' = #h_field_b; field: 'h_field_c' = #h_field_c; log: true)
Create a custom button in the cycles table that calls a temporary table with some parameters for creating a cycle.
Connect this button to the row part buttons using the buttons
parameter of the setTableFormat
function in the Table Formatting section.
Disable the standard add button by removing the Addition
parameter in the cycles table settings.