Which function opens the input window?
linkToInput — it will open a small window with an input field and two buttons — execute action
and close
.
When the execute action button is pressed (its name can be set by the parameter button: "Button Text"
), the code passed in code
is executed.
When this code is executed, the value entered in the input field will be available in the variable $#input
.
What are the ways to pass code to it for later execution?
code
can be specified in several ways:
as text — code: "=: set(table: $#ntn; field: 'field' = $#input)"
name
of the field in the same table from which the action code will be taken — code: "field_with_code"
.
=: linkToInput(html: "Enter order number"; title: "Open order by number"; code: $stradd; button: "Open")
stradd: str`'=: linkToTable(table: "sostav_zakaza"; cycle: $number; target: "top")' + $#nl + 'number: select(table: "novye_zakazy"; field: "id"; where: "nomer" = $#input)'`
// Note that we concatenate multi-line code using $#nl
Since the example above is extremely inconvenient, starting from version 2 there is such an option:
=: linkToInput(html: "Enter order number"; title: "Open order by number"; code: $code; button: "Open")
```code:totum
=: linkToTable(table: "sostav_zakaza"; cycle: $number; target: "top")
number: select(table: "novye_zakazy"; field: "id"; where: "nomer" = $#input)
```
In this case, everything that appears on the highlighted background will be passed as plain text!
Is it possible to pass code with a standard link to a line of code?
No. If you do it like this:
=: linkToInput(html: "Enter order number"; title: "Open order by number"; code: $stradd; button: "Open")
stradd: linkToTable(table: "sostav_zakaza"; cycle: $number; target: "top")
number: select(table: "novye_zakazy"; field: "id"; where: "nomer" = $#input)
// This example is INCORRECT — it will NOT work:
Then it won't work.
Is the environment (table, row id, field name) passed when linkToInput is called?
By default, the code receives some environment parameters:
$#ntn
— the name of the table from which input
is called
$#nh
— the hash of the current table (we will discuss this in advanced action codes)
#
— all hashes of the current table.
Other variables can be passed through the parameter var: "var_name" = "var_value"
.
Is there any other way to pass the code?
Yes. But it is better to use this option in some cases.
You can create a field of type Text with highlight type Totum-code
in any table.
Write the code in it, but specifically in the field value, not in the settings.
Retrieve this code through select
.
=: linkToInput(html: "Enter order number"; title: "Open order by number"; code: $select; button: "Open")
select: select(table: 'table'; field: 'code_field')
// if this table stores several codes in rows, then you need to add where
The same through sugar for select:
=: linkToInput(html: "Enter order number"; title: "Open order by number"; code: @table.code_field; button: "Open")
// for fields placed in the header/footer
=: linkToInput(html: "Enter order number"; title: "Open order by number"; code: @table.code_field.name_field[name]; button: "Open")
// for fields placed in the row part with search by where: 'name_field' = "name"