# Define a Task to run a Script

&#x20;It is possible inside Bizagi to define a task as script to run:

![](/files/-LHABz50FQGuWUH-1D8n)

&#x20;In this case the first task of the process is to run a **Script**. To define a **Task** as **Script** in **Bizagi** select the **Task** click on mouse right button (this will display the context menu) select "**Task Type**" and the click on "**Script Task**".

![](/files/-LHAC3J4xdOekyLwBnUX)

The Script must be a Block Closure with two arguments:\
`[:script :process | ]`.\
\
&#x20;The first argument is the process itself (an instance of BpmProcessInstance) and the second argument is the script itself (an instance of BpmScriptTaskInstance).\
&#x20;The script accept variable definitions that can be stored inside the script:

```
[:script :process |  | tempVar |
script setVariableNamed: 'stamp' withValue: TimeStamp now.
(process transactionAmount > 1000) 
ifTrue: [process doSomething] 
ifFalse: [process doOtherThing]
].
```

To set the script code in **Bizagi**:

![](/files/-LHACALtve8mxTzFBXkN)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bpmflow.gitbook.io/project/application-manuals/backoffice-manual/main-menu/processes/define-new-process/define-a-task-to-run-a-script.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
