# System

System actions. For advanced users.

### Static properties

#### appUrl *string*

Gets the Rulecube application URL. Ends with a forward slash, e.g. <https://app.rulecube.com/>

#### apiUrl *string*

Gets the Rulecube API URL. Ends with a forward slash, e.g. <https://app.rulecube.com/api/>

### Methods

#### alertInfo

```javascript
alertInfo(name: string, title: string, message: string, alertOptions?: { 
    type?: "alert" | "warning" | "error",
    name?: string,
    title?: string,
    code?: any,
    property?: string,
    propertyValue?: any,
    ruleId?: any,
    priority?: number,
    group?: string,
    entityName?: string,
    message?: string,
    messageError?: string
})
```

Creates and triggers an alert with the given message and type 'info'.

**Parameters**

&#x20;   **name&#x20;*****string***

&#x20;       The name.

&#x20;   **title&#x20;*****string***

&#x20;       The title.

&#x20;   **message&#x20;*****string***

&#x20;       The message.

&#x20;   **alertOptions&#x20;*****{ type?: "alert" | "warning" | "error", name?: string, title?: string, code?: any, property?: string, propertyValue?: any, ruleId?: any, priority?: number, group?: string, entityName?: string, message?: string, messageError?: string}***

&#x20;       (optional) The object containing the alert options.

**Return type**

&#x20;   void

**Examples**

```javascript
System.alertInfo('a', 'The title', 'The message.')
```

#### alertWarning

```javascript
alertWarning(name: string, title: string, message: string, alertOptions?: { 
    type?: "alert" | "warning" | "error",
    name?: string,
    title?: string,
    code?: any,
    property?: string,
    propertyValue?: any,
    ruleId?: any,
    priority?: number,
    group?: string,
    entityName?: string,
    message?: string,
    messageError?: string
})
```

Creates and triggers an alert with the given message and type 'warning'.

**Parameters**

&#x20;   **name&#x20;*****string***

&#x20;       The name.

&#x20;   **title&#x20;*****string***

&#x20;       The title.

&#x20;   **message&#x20;*****string***

&#x20;       The message.

&#x20;   **alertOptions&#x20;*****{ type?: "alert" | "warning" | "error", name?: string, title?: string, code?: any, property?: string, propertyValue?: any, ruleId?: any, priority?: number, group?: string, entityName?: string, message?: string, messageError?: string}***

&#x20;       (optional) The object containing the alert options.

**Return type**

&#x20;   void

**Examples**

```javascript
System.alertWarning('a', 'The title', 'The message.')
```

#### alertError

```javascript
alertError(name: string, title: string, message: string, alertOptions?: { 
    type?: "alert" | "warning" | "error",
    name?: string,
    title?: string,
    code?: any,
    property?: string,
    propertyValue?: any,
    ruleId?: any,
    priority?: number,
    group?: string,
    entityName?: string,
    message?: string,
    messageError?: string
})
```

Creates and triggers an alert with the given message and type 'error'.

**Parameters**

&#x20;   **name&#x20;*****string***

&#x20;       The name.

&#x20;   **title&#x20;*****string***

&#x20;       The title.

&#x20;   **message&#x20;*****string***

&#x20;       The message.

&#x20;   **alertOptions&#x20;*****{ type?: "alert" | "warning" | "error", name?: string, title?: string, code?: any, property?: string, propertyValue?: any, ruleId?: any, priority?: number, group?: string, entityName?: string, message?: string, messageError?: string}***

&#x20;       (optional) The object containing the alert options.

**Return type**

&#x20;   void

**Examples**

```javascript
System.alertError('a', 'The title', 'The message.')
```

#### alert

```javascript
alert(alertOptions: { 
    type?: "alert" | "warning" | "error",
    name?: string,
    title?: string,
    code?: any,
    property?: string,
    propertyValue?: any,
    ruleId?: any,
    priority?: number,
    group?: string,
    entityName?: string,
    message?: string,
    messageError?: string
})
```

Creates and triggers an alert with the given options object.

**Parameters**

&#x20;   **alertOptions&#x20;*****{ type?: "alert" | "warning" | "error", name?: string, title?: string, code?: any, property?: string, propertyValue?: any, ruleId?: any, priority?: number, group?: string, entityName?: string, message?: string, messageError?: string}***

&#x20;       The object containing the alert options.

**Return type**

&#x20;   void

**Examples**

```javascript
System.alert({
    type: 'warning',
    name: 'a',
    title: 'The title',
    message: 'The message',
    id: 1001
})
```

#### createEntity

```javascript
createEntity(entityName: string, constructorObject?: { [key: string]: any; })
```

Creates an entity based on the name. Chain with `.to()` to cast to the proper Entity type.

**Parameters**

&#x20;   **entityName&#x20;*****string***

&#x20;       The name of the entity.

&#x20;   **constructorObject&#x20;*****{ \[key: string]: any; }***

&#x20;       (optional) The object to pass as the parameter to the constructor of the entity.

**Return type**

&#x20;   RuleSetBaseEntity

**Examples**

```javascript
System.createEntity('Person', { Name: 'Test' }).to(Person)    // => a Person entity 
```

#### setMetricInput

```javascript
setMetricInput(metricName: string, metricValue: any)
```

Sets a metric input by name and value. Will overwrite any existing value by the same name. Note that metrics will need to be enabled in the version settings and execution options for this to work.

**Parameters**

&#x20;   **metricName&#x20;*****string***

&#x20;       The name of the metric.

&#x20;   **metricValue&#x20;*****any***

&#x20;       The value of the metric.

**Return type**

&#x20;   void

**Examples**

```javascript
System.setMetricInput('Foo', 1)
```

#### setMetricOutput

```javascript
setMetricOutput(metricName: string, metricValue: any)
```

Sets a metric output by name and value. Will overwrite any existing value by the same name. Note that metrics will need to be enabled in the version settings and execution options for this to work.

**Parameters**

&#x20;   **metricName&#x20;*****string***

&#x20;       The name of the metric.

&#x20;   **metricValue&#x20;*****any***

&#x20;       The value of the metric.

**Return type**

&#x20;   void

**Examples**

```javascript
System.setMetricOutput('Foo', 1)
```

#### setNextInput

```javascript
setNextInput(inputName: string, nextValue: any)
```

Instructs the system to use a new value for an input in the next run. Used in combination with `System.restart()`.

**Parameters**

&#x20;   **inputName&#x20;*****string***

&#x20;       The name of the input.

&#x20;   **nextValue&#x20;*****any***

&#x20;       The value of the input in the next run.

**Return type**

&#x20;   void

**Examples**

```javascript
System.setNextInput('Foo', Foo + 1)
```

#### restart

```javascript
restart()
```

Instructs the system to run the ruleset again with potentially new input.

**Parameters**

**Return type**

&#x20;   void

**Examples**

```javascript
System.restart()
```

#### stop

```javascript
stop(message?: string)
```

Instructs the system to stop ruleset execution.

**Parameters**

&#x20;   **message&#x20;*****string***

&#x20;       (optional) The message returned by the ruleset as the reason for stopping execution.

**Return type**

&#x20;   void

**Examples**

```javascript
System.stop()
System.stop('stop the ruleset')
```

#### getCulture

```javascript
getCulture()
```

Returns the current culture (language).

**Parameters**

**Return type**

&#x20;   string

**Examples**

```javascript
System.getCulture()
```

#### isTest

```javascript
isTest()
```

Returns whether the system is running in test mode. This is true when a Testcase is executed.

**Parameters**

**Return type**

&#x20;   boolean

**Examples**

```javascript
System.isTest()
```

#### getTestName

```javascript
getTestName()
```

Returns the current Testcase name if any.

**Parameters**

**Return type**

&#x20;   string

**Examples**

```javascript
System.getTestName()
```

#### getTestCase

```javascript
getTestCase()
```

Returns the current Testcase object if any.

**Parameters**

**Return type**

&#x20;   { \[key: string]: any; }

**Examples**

```javascript
System.getTestCase()
```


---

# 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.rulecube.com/language-reference/system.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.
