Question
There is a table of cycles, and each cycle contains 2 Calculation tables. One group of users should have access only to the second table. When access to the first calculation table in the cycle is restricted, a user from the specified group is immediately transferred to the first calculation table, to which access is prohibited, when creating a new cycle. How can they be swapped so that when a user from the specified group creates a new cycle, they are immediately transferred to the second table?
Answer
To customize the cycle creation process, it is necessary to hide the standard Add button in the cycle table settings ā this is done by setting the add option in the table to disabled.
Next, we create a button in the header of the cycle table, where in the action code we perform two actions: adding a row to the cycle table and obtaining the id of the added row, and the second action is transitioning to the required cycle table, which is selected based on the current user's role.
Action code for the custom Add button:
a1=: insert(table: $#ntn; inserts: "new_cycle_id"; log: true)
a2=: linkToTable(table: $if_table; cycle: $#new_cycle_id[0]; target: "self")
if_table: if(condition: $#nr = 2; then: "table_inside_2"; else: "table_inside_1")