# Script Templates

Script Templates are used to easily create a new scripts together with test contexts. Right click on any script folder where you want to create a ***New -> Boomi Process Script**.*

<figure><img src="/files/AyjTUqoVvAOvRF5zASaN" alt=""><figcaption><p>Use IntelliJ Templates</p></figcaption></figure>

* Give the script a meaningful name.
  * <mark style="color:green;">**DO use**</mark> characters, numbers and underline only.
  * <mark style="color:red;">**DO NOT**</mark> use <mark style="color:red;">**spaces**</mark> or special characters: <mark style="color:red;">`-/&(){},[]`</mark> etc.
  * <mark style="color:green;">**DO use**</mark> either`CamelCase, camelCase` or `lower_case` notation.
* Write one line about the purpose of the script.
* and you your shortcut as the author

<figure><img src="/files/nZzyouHUcy2pVOpr6RBz" alt=""><figcaption><p>Create a new Boomi Process Script based on a template</p></figcaption></figure>

{% hint style="info" %}
The script filename starts with `psg<BoomiScriptName>` as the naming convention for **P**rocess **S**cript **G**roovy: **`psg`**`MyFirstScript.groovy`.
{% endhint %}

The Script file **`psgMyFirstScript.groovy`** is created with the following content:

```groovy
final String SCRIPT_NAME = "MyFirstScript"

/* **************************************************************************
    This is my first script.
        
    IN : [Describe inbound arguments]
    OUT: [Describe outbound arguments]
    ------------------------------------------------
    12.05.2024  mspro -   Created
    Template v0.2.1
************************************************************************** */

final _logger = ExecutionUtil.getBaseLogger()
_logger.info('>>> Script start ' + SCRIPT_NAME)
...
for (int docNo = 0; docNo < docCount; docNo++) {
	final String textDoc = _getTextDocument( docNo)
	final Properties props = dataContext.getProperties(docNo)
	// *********** Document related functionality ************
	
	// Your document related code here ...
	
	// ******** end of Document related functionality ********
	_setTextDocument( textDoc, props)
}
...
```

## Create a new Test Context

To run a Boomi Script we need a Test Context.&#x20;

When you create a ***New -> Boomi Process Script Test***, provide the script's name that you used when creating the script: `final String SCRIPT_NAME = "`*`MyFirstScript`*`"`

<figure><img src="/files/wKkBbiH74FfSMicMBbXA" alt=""><figcaption><p>Create a new Test Class for <em>MyFirstScript</em></p></figcaption></figure>

```groovy
@TypeChecked
class Test_psgCalcTotal {
	final String SCRIPT_NAME = "psgCalcTotal"

	@SourceURI
	URI _sourceUri
	final ProcessScript _testScript 
	  = new ProcessScript("psg" + SCRIPT_NAME + ".groovy", _sourceUri)

	/** A short description what this test is supposed to do. */
	@Test
	void test01() { ... }
}

```

### Run the Test

You can **run or debug the Test** right from there:

<div align="left"><figure><img src="/files/bvemXeXLbhG13Azqk9ON" alt=""><figcaption><p>Run or debug script</p></figcaption></figure></div>


---

# 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://boomi.markusschmidt.pro/boomi-scriptease/knowlede-base/process-script-templates.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.
