To enhance basic workflow functionality, server-side scripts can be used in workflow blocks. In addition to Server-Side API classes, the following three can be used in workflow scripts:
Current
Scratchpad
Activity
The Current object is a instance, for which a workflow context has been created. The property names of the Current object match the names of the record columns (Column Name attribute). The full list of class methods is described in this article.
The Scratchpad object is an associative array (JSON), into which you can place values to later use them within the context. The value of the object is stored in the Scratchpad field of the Workflow Context.
The Activity object is a instance of the current block record. The Activity object properties match the names of record columns (Column Name attribute) in the Workflow Executing Activity [wf_executing_activity] table. For the Task [task] and Approval [sys_approval] records in the Wf Executing Activity field a reference to the linked Executing Activity record is specified.
Global objects in a workflow
Below is a workflow example for the Task [task] table.
In the beginning of the process a Task [task] child record is created through the Create Child Task block. Then the process is stopped on the block to wait for In Progress state.
After the state is changed to In Progress, the process proceeds to the Update Child Task block, in which the Task child record is updated:

The block is used to create a Task record according to its settings. The ID of the current record is specified in its Parent field:
new_task.parent_id = current.sys_id;

To update a record its ID must be known. However, the block does not return the ID of the created record.
For a record that is created via the generator block the Wf Executing Activity field is filled in. In this field a link to the executable block, within which the Task record was created, is specified.
To search for the created record it is possible to use sampling from the Task table by Wf Executing Activity field.
Scratchpad is used to record the ID value of the block:
const curentExecActivityId = activity.sys_id;
scratchpad.recGeneratorActivityId = curentExecActivityId;
The block named Update Child Task searches for the Task record and updates it:
const task = new SimpleRecord('task');
task.get('wf_executing_activity', scratchpad.recGeneratorActivityId);
if (task.sys_id) {
task.state = '3'; // In Progress
task.update();
}