Prework scripts are commonly used to control process data or task state before it's assigned to the users.
Prework script defined area is reached from a related task. When you click on the "Prework script" button on the task, prework script page will open.
Example:
In prework script following objects are available:
$WorkItem
Current workitem instance.
$Xml
Xml data navigator for data model.
Error rendering macro 'excerpt-include' : User 'null' does not have permission to view the page 'EMK:_InstanceScriptingObjects'.
Error rendering macro 'excerpt-include' : User 'null' does not have permission to view the page 'EMK:_GlobalScriptingObjects'.
Common operations
Auto Process Task
Automatically processes current work item, without assigning it to the users, and skips to the next step of a workflow.
Assign action
$WorkItem.SelectedAction = 'Approve';
Dynamic Deadline Date
Sets deadline date by user entered data.
Assign action
$WorkItem.DeadlineDate = $Xml.EvaluateDateTime('PaymentDate');