# Connection Functions

Connection functions allow you to manage connections on the inSCADA platform with script/expression. With these functions you can run, stop and check the status of connections.

## Get Connection Status

#### String ins.getConnectionStatus(String connectionName)

Provides information about the status of a connection.

connectionName: The connection name.

Return Value: Returns a string containing information about the connection status. ("Connected","Disconnected")

#### Syntax

```javascript
var status=ins.getConnectionStatus("Connection_01");
if (status==="Disconnected") {
    ins.notify("error","Connection 01","Connection 01 is fail");
}
```

#### String ins.getConnectionStatus(Integer connectionId)

Returns information about a connection status.

connectionId: The ID of the connection.

Return Value: Returns a string containing information about the connection status. ("Connected","Disconnected")

#### Syntax

```javascript
var connectionId=1;
var status=ins.getConnectionStatus("Connection_01");
if (status==="Disconnected") {
    ins.notify("error","Connection 01","Connection 01 is fail");
}
```

{% hint style="info" %}
ConnectionId is a unique registration number in the database on connections in the inSCADA Platform. It is not displayed on the platform. However, this information can be taken from value expression using the self expression (self.connectionId). This allows you to write expressions that can check the overall connection status.
{% endhint %}

## Start Connection

#### startConnection(String connectionName)

Starts a connection.

connectionName: The connection name.

Return Value: Does not return any value.

```javascript
if (ins.getConnectionStatus("Connection_01")==="Disconnected") {
    ins.startConnection("Connection_01");
}
```

## Stop Connection <a href="#stop-connection" id="stop-connection"></a>

#### stopConnection(String connectionName) <a href="#stopconnection-string-connectionname" id="stopconnection-string-connectionname"></a>

Stops a connection.

connectionName: The connection name.

Return Value: Does not return any value.

#### Syntax

```javascript
if (ins.getConnectionStatus("Connection_01")==="Connected") {
    ins.stopConnection("Connection_01");
}
```


---

# 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://inscada.gitbook.io/ins/en-1/programing/apis/connection-functions.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.
