Question
The cycle table contains 3 calculation tables. The user needs access to the cycle table itself and only to the latest calculation table (for example, with sort 30). When navigating from the cycle table, the transition is only made to the first one with sort 10, to which access is prohibited. How can one access any other table instead of the first one?
Answer
It is necessary to modify the Open button code (a standard field in the cycle table, created automatically). By default, it does not take into account access to tables:
=: linkToTable(table: $table_search; cycle: #id; target: 'self' )
table_search: if(condition: $filter = $#lc; then: $error; else: $filter[0][id])
~filter: listFilter(list: $combine_roles; key: "roles" = $#nr)
error: errorException(text: "No have available tables")
combine_roles: listReplace(list: $tables; action: "roles" = $roles; value: "value")
tables: selectRowList(table: 'tables'; field: 'edit_roles'; field: 'read_roles'; field: 'id'; where: 'type' = "calcs"; where: 'tree_node_id' = $#nti; order: 'sort')
roles: listUniq(list: $listadd)
listadd: listAdd(list: $#value[edit_roles]; list: $#value[read_roles])
Tables are stored in tables, and we will check edit_roles and read_roles. We will take the list of tables that relate to the current cycle table, sorted by sort in ascending order. First, using listReplace, we will combine the roles into one field roles and then filter this list according to the current user's roles.
If there is a match, the list will be non-empty, and we will take the table id from the first row. If there are no matches, the list will be empty (no table is available), and an error will be displayed.