Scripts Tasks (Reference) are automated program units that execute in response to events or on scheduled intervals, providing the core automation logic for your FrameworX solution. ScriptTask is a self-contained code blocks that:
Unlike Script Classes, Tasks don't require method declarations - you write directly the code to be executed, similar to the contents of a method body.
Property | Description |
---|---|
Name | Task identifier used in runtime references |
Code | Programming language (VB.NET, C#, Python) |
Domain | Execution location: Server (default) or Client |
Trigger | Event that initiates task execution |
Period | Time interval for periodic execution |
InitialState | Enabled (ready to run) or Disabled |
BuildStatus | ? Green = Success, ? Red = Errors |
BuildErrors | Compilation error count |
EditSecurity | Permission level required to modify |
Property | Description |
---|---|
ID | Unique task identifier |
VersionID | Modification version counter |
Lines | Code line count |
BuildMessage | Compilation messages |
Category | Task grouping category |
LockState | Edit lock status |
DateCreated | Creation timestamp |
DateModified | Last modification timestamp |
<ac:structured-macro ac:name="warning"> ac:rich-text-body Important: Script Tasks contain only the method body code - no function declarations or wrappers. The platform automatically handles method creation, exception protection, and thread management. </ac:rich-text-body> </ac:structured-macro>
csharp
// Direct code - NO method declaration
double temperature = @Tag.Temperature;
if (temperature > 100)
{
@Tag.AlarmActive = true;
@Alarm.Notify("High Temperature");
}
csharp
// ? WRONG - Do not include method wrapper
public void ProcessTemperature()
{
// Code here
}
All solutions include predefined tasks:
Tasks execute when specific events occur:
Configure periodic execution:
<ac:structured-macro ac:name="info"> ac:rich-text-body Default Configuration: Client-side tasks are disabled by default in Solution Settings because web clients don't support them yet. Most solutions use only server-side tasks. </ac:rich-text-body> </ac:structured-macro>
Server Domain (Default):
Client Domain (When Enabled):
Access task runtime information via @Script.Task
namespace:
csharp
// Access task properties
int count = @Script.Task.MyTask.ExecutionCount;
TimeSpan cpu = @Script.Task.MyTask.LastCPUTime;
bool enabled = @Script.Task.MyTask.Enabled;
// Control task execution
@Script.Task.MyTask.Run(); // Force execution
@Script.Task.MyTask.Enabled = false; // Disable task
Property | Type | Description |
---|---|---|
ExecutionCount | Integer | Number of executions |
LastCPUTime | TimeSpan | CPU time of last execution |
Enabled | Boolean | Task enable state |
IsRunning | Boolean | Currently executing |
LastError | String | Last execution error |
csharp
// Direct access to Script Classes
var result = @Script.Class.Calculations.Process(100);
csharp
// All namespaces available
@Tag.Temperature = 25;
@Alarm.Reset("Area1");
var data = @Dataset.Query("SELECT * FROM Production");
@Display.MainScreen.Open();
vbnet
' Use Exit Function to stop execution
If temperature > 100 Then
Exit Function
End If
csharp
// Use return to stop execution
if (temperature > 100)
{
return;
}
python
# Standard Python syntax
if temperature > 100:
return
Task not executing:
Performance issues:
Compilation errors: