# Variables in workflows and contracts

This section describes the **interactions between workflows and contracts**, including the variables that can be configured in a workflow and are initialized in the contract. The **filters** to be configured in a contract against specific triggers and how to use custom scripts, through a service called Script Task, are given as well.&#x20;

| Name                            | Field                             | Description                                                                                                                  |
| ------------------------------- | --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| BOOLEAN                         | Boolean                           | Select True/False                                                                                                            |
| CLUSTER                         | Cluster                           | Select with the Cluster List                                                                                                 |
| CODE\_PAGE                      | File Code Page                    | Select with the enum (/ghibli-rest/v2/resources/enums/Charsets)                                                              |
| COMPRESSION                     | Compression                       | Select with the enum (/ghibli-rest/v2/resources/enums/Compression)                                                           |
| COMPRESSION\_STRATEGY\_LEVEL    | Compression strategy level        | Select with the enum (/ghibli-rest/v2/resources/enums/CompressionStrategyLevel)                                              |
| CRON\_EXPRESSION                | Cron expression                   | Cron expr wizard                                                                                                             |
| DATE                            | Date                              | Input type date                                                                                                              |
| DATETIME                        | Date time                         | Input type date-time                                                                                                         |
| DECIMAL                         | Decimal                           | Input type numeric                                                                                                           |
| ENUM                            | List                              | Input type string                                                                                                            |
| EOL                             | File End of Line type             | Select with the enum (/ghibli-rest/v2/resources/enums/ResourceEol)                                                           |
| EXPRESSION                      | Expression                        | Input type text                                                                                                              |
| FILE                            | File                              | Input type text                                                                                                              |
| INTEGER                         | Integer                           | Input type numeric                                                                                                           |
| LONG                            | Long                              | Input type numeric                                                                                                           |
| RESOURCE\_PROFILE               | Resource profile                  | ([Cascader](https://ant.design/components/cascader) all the file resources associated with the selected partner and company) |
| SECURITY\_CHIPER\_ALGO          | Security Cipher Algorithm         | Select with the enum (/ghibli-rest/v2/resources/enums/SecurityCipherAlgorithm)                                               |
| SECURITY\_OPERATION             | Security Operation                | Select with the enum (/ghibli-rest/v2/resources/enums/SecurityOperation)                                                     |
| SECURITY\_SIGNATURE\_HASH\_ALGO | Security Signature Hash Algorithm | Select with the enum (/ghibli-rest/v2/resources/enums/SecuritySignatureHashAlgo)                                             |
| STRING                          | String                            | Input type time                                                                                                              |
| TIME                            | Time                              | Input type time format hh:mm:ss SSS                                                                                          |
| TIMEZONE                        | Time zone                         | Select with the Timezone List                                                                                                |
| TRANSFER\_PROFILE               | Transfer profile                  | ([Cascader](https://ant.design/components/cascader) all the remote servers associated with the selected partner and company) |
| VIRTUAL\_PATH                   | Virtual path                      | ([Cascader](https://ant.design/components/cascader) all the virtual paths associated with the selected partner and company)  |

## Filter

A **Filter** field is associated with each flow template triggered by a **NewFile** or an **IncomingTransfer** event, and a new instance is fired only when the filter is satisfied.

If the Filter is empty, a new instance is created regardless of the file.

The syntax used in the expression uses Groovy scripting. You do not need to know the entire Groovy language. It is enough to know its operators to build correct expressions that return a true or false variable.

| Operator | Purpose               |
| -------- | --------------------- |
| =        | equal                 |
| !=       | different             |
| <        | less than             |
| <=       | less than or equal    |
| >        | greater than          |
| >=       | greater than or equal |
| &&       | logical "and"         |
| \|\|     | logical "or"          |
| !        | logical "not"         |

These operators will work on objects and their properties.

Below you can find some examples of real cases.&#x20;

## **Trigger Type: NEW FILE**

File variable created when the **NewFile** trigger starts an instance. It is referred to as **file** and its values come from the **filesetEvent** with a structure like this:

```shell
file {
  registryId = 11
  clusterName = "cluster1"
  virtualPath = "part1-vfs:/inbox"
  virtualFolder = "/inbox"
  virtualFS = "part1-vfs"
  name = "myFileName.txt"
  nameNoExtension = "myFileName"
  extension = "txt"
  absoluteFileName = "/home/ghibli/vfs/internal-volume/myFileName.txt.A00069E0.B0EA621E"
}
```

```shell
filesetEvent {
  fsrFilesetId = 9
  internalFile = true
  absoluteFilename = "/home/ghibli/vfs/internal-volume/myFileName.txt.A00067B6.B8519525"
  fileAccessUrl = "file:/home/ghibli/vfs/internal-volume/myFileName.txt.A00067B6.B8519525"
  originalFileName = "myFileName.txt"
  resourceId = "3f18857208cc5640d2fa0ab7a596ea28d40a923d"
  virtualPath = "part1-vfs:/inbox"
  creationTimestamp = null
  updateTimestamp = null
  databox = "part1-vfs:/inbox"
  databoxVersion = 0
  peerId = null
  clusterName = "cluster1"
  eventUTCDate = "Thu Jul 19 11:35:44 CEST 2018"
  timezoneId = "Europe/Rome"
  userName = null
  errorMessage = null
  errorMsgArgs = null
}
```

## **Trigger Type: INCOMING/OUTGOING TRANSFER**

File variable created when the **IncomingTransfer** trigger or the **OutgoingTransfer** trigger starts an instance. It is referred to as **file** and its values come from the **transferEvent** with a structure like this:

```shell
file {
  registryId = 11
  clusterName = "cluster1"
  virtualPath = "part1-vfs:/inbox"
  virtualFolder = "/inbox"
  virtualFS = "part1-vfs"
  name = "myFileName.txt"
  nameNoExtension = "myFileName"
  extension = "txt"
  absoluteFileName = "/home/ghibli/vfs/internal-volume/myFileName.txt.A00069E0.B0EA621E"
}
```

```shell
transferEvent {
  eventId = "/b3705c37-a39c-423b-a0a2-3a8dbb6d39bc/86df2978-720c-46f8-bf34-aa9be4d0384c"
  eventType = "NOTIFICATION"
  eventUTCDate = "2020-06-12 09:55:59,995 +0200"
  timezoneId = "CET"
  emitterType = "TRANSPORT"
  eventSeverity = "OK"
  eventClassification = "TRANSFER_EVENT"
  peerId = "peer1"
  clusterName = "cluster1"
  userName = "part1"
  errorMessage = null
  errorMsgArgs = null
  transferId = 2018
  transferStatus = "COMPLETED"
  direction = "PUSH"
  mode = "SERVER"
  fsrFilesetId = 55
  filesize = 0
  sourceFile = "/test8.txt"
  destinationFile = "//IVNQM1/LOCALE/test8.txt"
  protocol = "FTP"
  tag = "test8.txt"
  transferRetry = 0
  sender = "172.18.0.1"
  contract = null
  contractVersion = 0
  databox = "part1-vfs:/IVNQM1/LOCALE"
  databoxVersion = 0
  partner = "part1
  partnerVersion = 0
  incomingcall = null
}
```

## **Trigger Type: INCOMING UPDATE METADATA**

File variable created when the **IncomingUpdateMetadata** trigger starts an instance. It is referred to as **file** and its values come from the **filesetMetadataEvent** with a structure like this:

```shell
file {
  registryId = 11
  clusterName = "cluster1"
  virtualPath = "part1-vfs:/inbox"
  virtualFolder = "/inbox"
  virtualFS = "part1-vfs"
  name = "myFileName.txt"
  nameNoExtension = "myFileName"
  extension = "txt"
  absoluteFileName = "/home/ghibli/vfs/internal-volume/myFileName.txt.
A00069E0.B0EA621E"
}

filesetMetadataEvent {
  fsrFilesetId = 9
  internalFile = true
  absoluteFilename = "/home/ghibli/vfs/internal-volume/myFileName.txt.
A00067B6.B8519525"
  fileAccessUrl = "file:/home/ghibli/vfs/internal-volume/myFileName.txt.
A00067B6.B8519525"
  originalFileName = "myFileName.txt"
  resourceId = "3f18857208cc5640d2fa0ab7a596ea28d40a923d"
  virtualPath = "part1-vfs:/inbox"
  creationTimestamp = null
  updateTimestamp = null
  databox = "part1-vfs:/inbox"
  databoxVersion = 0
  peerId = null
  clusterName = "cluster1"
  eventUTCDate = "Thu Jul 19 11:35:44 CEST 2018"
  timezoneId = "Europe/Rome"
  userName = null
  errorMessage = null
  errorMsgArgs = null
  metadata = {
    key1 = "value1"
    key2 = "value2"
  }
}
```

Here below, you can find a couple of examples to better understand how the **Filter** behaves, according to sample data provided, with some of the following expressions specified in the contract:

**Expression**:\
`file.registryId==666`\
**Result**:\
**FALSE**, no instance will be created

**Expression**:\
`file.registryId==11`\
**Result**:\
**TRUE**, a new instance will be created

**Expression**:\
`file.name=="myFileName.txt" && filesetEvent.clusterName=="clusterFake"`\
**Result**:\
**FALSE**, no instance will be created

**Expression**:\
`file.name=="myFileName.txt" && filesetEvent.clusterName=="cluster1"`\
**Result**:\
**TRUE**, a new instance will be created

**Expressions that will return TRUE according to above provided data**:\
`file.name.contains("ileNam") && file.extension == "txt"`\
`file.name.matches("myFileName.txt")`\
`file.name.matches("myFileNam(.*)")`\
`file.name.startsWith("myFil")`

**Syntax scripting Filter field**

| <p>- <strong>Syntax</strong><br>Boolean matches(String regex)<br><br>- <strong>Meaning</strong><br>Tests whether this string matches the desired regular expression (with regular expression syntax).<br><br>- <strong>Parameters</strong><br>Regex − the expression for comparison.</p> |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p>- <strong>Syntax</strong><br>Boolean startsWith(String prefix)<br><br>- <strong>Meaning</strong><br>Tests whether this string starts with the specified prefix.<br><br>- <strong>Parameters</strong><br>Prefix – The prefix to search for</p>                                         |
| <p>- <strong>Syntax</strong><br>Boolean endsWith(String suffix)<br><br>- <strong>Meaning</strong><br>Tests whether this string ends with the specified suffix.<br><br>- <strong>Parameters</strong><br>Suffix – The suffix to search for</p>                                             |
| <p>- <strong>Syntax</strong><br>Boolean isEmpty()<br><br>- <strong>Meaning</strong><br>Tests whether this string has a value.<br><br>- <strong>Parameters</strong><br>NA</p>                                                                                                             |


---

# 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://docs.primeur.com/data-mover-1.21/workflow-templates/variables/variables-in-workflows-and-contracts.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.
