# RAISEEXCEPTION Workflow Application

## Overview

The **RAISEEXCEPTION** workflow application raises the cancel exceptions on specified actions, as controlled by the action cancellation workflow exception in the conditions definition panel. This workflow application can thus be called by an action to cancel one or several other actions in a running request. The application is converted as an assembly workflow to simplify configuration and improve performance.

{% hint style="info" %}
The RAISEEXCEPTION web app in IIS and the file system folder (`\wfgen\WfApps\WebServices\RaiseException`) can be disabled and removed. Authentication settings at the application level are not required.
{% endhint %}

This feature is useful when one or more actions need to be cancelled after a certain point in the workflow has been reached, even though those actions have already been activated. For example, if three parallel actions are ongoing, but one of the parallel actions is concluded ahead of the others and your workflow rules have determined that the two other actions are no longer required, you can activate RAISEEXCEPTION to cancel the other two actions and allow the workflow to continue.

Additionally, you can:

* Use default parameters to cancel all open actions in a specific request.<br>
* Use optional parameters to cancel a list of action instantiations in a list of requests or to cancel on behalf of a specific user.<br>
* Use additional parameters to define multiple pairs of action references.

## Default parameters

The `REQUEST_ID` and `ACTIVITY_NAME` parameters must always be used together.

| Parameter       | Type    | Direction | Description                                          |
| --------------- | ------- | --------- | ---------------------------------------------------- |
| `REQUEST_ID`    | Numeric | IN        | ID of the request where the action will be cancelled |
| `ACTIVITY_NAME` | Text    | IN        | Name of the action that will be cancelled            |

#### 📌 Example

In this example, the application will cancel all instances of the `PENDING_ACTION` action in request `455`:

```
REQUEST_ID = 455  
ACTIVITY_NAME = "PENDING_ACTION"
```

## Optional parameters

The `REQUEST_ID_LIST` and `ACTIVITY_NAME_LIST` parameters must always be used together.

| Parameter            | Type | Direction | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| -------------------- | ---- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `REQUEST_ID_LIST`    | TEXT | IN        | List of request IDs where the action will be cancelled                                                                                                                                                                                                                                                                                                                                                                                                     |
| `ACTIVITY_NAME_LIST` | TEXT | IN        | List of action names that will be cancelled                                                                                                                                                                                                                                                                                                                                                                                                                |
| `USERNAME`           | TEXT | IN        | <p>Used to set the username used to cancel the action <br><br>✏️ <strong>Notes:</strong></p><ul><li>This username must be part of a participant of the process.</li><li>If this parameter is not specified then the account used is the one specified as the <strong>Workflow engine service default identity</strong> in the <strong>Security</strong> section on the <strong>General</strong> tab in the <strong>Configuration Panel</strong>.</li></ul> |
| `PASSWORD`           | TEXT | IN        | Used to set the password corresponding to the username used to cancel the action                                                                                                                                                                                                                                                                                                                                                                           |
| `EXCEPTION_NAME`     |      |           | <p>Exception that will be triggered on the action<br></p><p><strong>Possible values:</strong></p><ul><li><code>CANCEL</code></li><li><code>ERROR</code></li><li><code>TIMEOUT</code></li><li><code>ASSIGNMENT\_ERROR</code></li></ul>                                                                                                                                                                                                                      |
| `EXCEPTION_MESSAGE`  |      |           | Used with the `ERROR` exception name to provide more details about the error in the follow-up action                                                                                                                                                                                                                                                                                                                                                       |

### Examples

In this example, the application will cancel all the instances of the actions `PENDING_ACTION1` and `PENDING_ACTION2` in each of requests `445`, `446`, and `447`:

```
REQUEST_ID_LIST = "455, 456, 457"  
ACTIVITY_NAME_LIST = "PENDING_ACTION1, PENDING_ACTION2"
```

In this example, the application will cancel all the instances of the action named `PENDING_ACTION` in request `445` on behalf of John Doe (`jdoe`):

```
REQUEST_ID = "455"  
ACTIVITY_NAME = "PENDING_ACTION"  
USERNAME = "jdoe"  
PASSWORD = "1234"
```

## Additional parameters

| Parameter                  | Type    | Direction | Description                                                                                                                                                                                                                                                                                        |
| -------------------------- | ------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `EX?_REQUEST_ID`           | Numeric | IN        | Indicates the ID of the request where the action will be cancelled for the pair specified by the `?` (question mark)                                                                                                                                                                               |
| `EX?_ACTIVITY_NAME`        | Text    | IN        | Indicates the name of the action that will be cancelled for the pair specified by the `?` (question mark)                                                                                                                                                                                          |
| `IGNORE_NOTHINGTODO_ERROR` | Text    | IN        | <p>Ignore <code>Nothing to do</code> error</p><p></p><p>By default, <code>RAISE\_EXCEPTION</code> returns an error if you try to cancel an action that doesn’t have any open instantiation. If you set this parameter value to <code>Y</code>, the application will ignore this type of error.</p> |

#### 📌 Example

In this example, the application will cancel all instances of the `PENDING_ACTION1` action in request `455` and all instantiations of the `PENDING_ACTION2` action in request `456`. If actions `455` and `456` have no instance then no error is raised.

```
EX1_REQUEST_ID = 455  
EX1_ACTIVITY_NAME = "PENDING_ACTION1"  
EX2_REQUEST_ID = 456  
EX2_ACTIVITY_NAME = "PENDING_ACTION2"  
IGNORE_NOTHINGTODO_ERROR = "Y"
```

## Possible execution errors

The following errors can occur during the execution of the transactions:

| Error                                                                                                                                                                                    | Cause                                                                                | Solution                                                                                                                                                                                                                                                                             |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| WorkflowGen Context is empty                                                                                                                                                             | All the `RAISE_EXCEPTION` parameters are empty                                       | Check the `RAISE_EXCEPTION` parameters.                                                                                                                                                                                                                                              |
| Application parameters are not correctly entered                                                                                                                                         | The `RAISE_EXCEPTION` parameters are not correctly filled                            | Check the `RAISE_EXCEPTION` parameters.                                                                                                                                                                                                                                              |
| <p>(WorkflowGen Web Exception)<br>HTTP Status: ...Response error: ... or The <code>FUNCTION\_NAME</code> parameter was not found</p>                                                     | An error occurred while trying to send the HTTP request  to WorkflowGen              | <p>Check the HTTP status:<br><code>401</code>: Security error <br></p><p>Check your authenticating parameters:</p><p><code>404</code>: Unable to connect to the URL</p><p><code>500</code>: Internal server error<br></p><p>Check for indications in the returned error message.</p> |
| <p>Error while trying to connect to WorkflowGen database<br>Error message: ...</p>                                                                                                       | An error occurred while trying to connect to the WorkflowGen database                | <p>Check your connection string in the configuration file.<br></p><p>Check for indications in the returned error message</p>                                                                                                                                                         |
| Parameters: `<Request Id parameter name>/<Activity Name parameter name>`, Error: WorkflowGen has raised a security exception.                                                            | The user defined by the `IDENTITY` parameters is not a participant of the process    | <p>Check <code>IDENTITY\_USERNAME</code> and <code>IDENTITY\_PASSWORD</code> parameters.</p><p></p><p>Identify the request with parameters names returned in the error message.</p>                                                                                                  |
| Parameters `<Request Id parameter name>/<Activity Name parameter name>`, Error: The activity name `<Activity Name>` doesn’t exist in the request `<Request Identifier>`.                 | One of the activity names defined in the `RAISE_EXCEPTION` parameters doesn’t exist. | <p>Check the <code>RAISE\_EXCEPTION</code> parameters.</p><p></p><p>Check for indications in the returned message.</p>                                                                                                                                                               |
| Parameters `<Request Id parameter name>/<Activity Name parameter name>`, Error: The action `<Activity Name>` doesn’t have any open instantiation in the request `<Request Identifier>`". | One of the actions to cancel is not open                                             | <p>Check the <code>RAISE\_EXCEPTION</code> parameters.</p><p></p><p>Check for indications in the returned message.</p><p></p><p>To ignore this error, set <code>IGNORE\_NOTHINGTODO\_ERROR</code> parameter to <code>Y</code>.</p>                                                   |
