Scripts
Updated
A script is C# the platform compiles in process. Metadata describes the object. The script is the behaviour metadata cannot express: fill a field, refuse a value, change a state, write a movement, share a calculation.
Note
Compiled code never leaves memory.
RuntimeCompilerloads every assembly into oneAssemblyLoadContextthat is never unloaded. A check compiles withcheckOnly: trueand does not load. Only code that will run is loaded.
Hosts#
| Host | When it runs | Kind / cookbook |
|---|---|---|
| Event handler | Save, a field on the card, a subtype transition | Write an event handler |
| Command | The user presses a button | Command |
| Posting script | The target subtype is posted | Posting script |
| Service | Another script calls GetService<IName>() |
Service |
| Form module | A standalone screen | Form |
| Data entity | Map to / from the OData projection | Data entity |
| Integration test | POST /api/metadata/tests/run-all |
Write an integration test |
Several handlers of one object, and several implementations of one IFoo, are Chain of Command: the top layer starts, next goes down.
A user partial is compiled with a generated framework half (helpers, GetResource). The pair *.script.json + *.cs is inseparable. Class names are unique across the workspace.
A script cannot open files, sockets, processes, or reflect around the platform. It does not author SQL: reads and writes go through IDataService / ISqlService inside the sandbox; going around them is refused. Outbound I/O is a channel by name. See what a script can do and outbound integrations.
Text a person will read is a resource, not a C# literal.
Related#
- Runtime — the compiler,
GetService, ClientActions - Metadata — the object the script is bound to
- Deep note: partial scripts and resources live in the kernel notes of this same Reference tree
Where next#
- Runtime
- Posting
- Command
- Posting script
- Permissions — Execute on a command is a matrix row, not a field