# SendMessage

| Bizerba SOAP API (\_connect.BRAIN) | Direct Communication TCP/IP |
| :--------------------------------: | :-------------------------: |
|                  ✓                 |              x              |

SendMessage is used to transmit BxNet commands to a device.

### Example Requests

#### Single Command

```javascript
let result = await app.businessFunction({
  //Common Parameters for all functions
  functionName: "BizerbaSoap",
  methodName: "SendMessage",
  silentMode: false, //false is default. If set to true, the Gebra Suite will not show an error message box. it is up to you to inform the user.
  
  url: "192.168.0.54", //The URL of Bizerba WebAPI
  device: "GLPmaxx", //Device to be addressed
  message: "A!GD10|USD;-2;333" //BxNet command
  timeout: 15 //Timeout in seconds for the request
});
```

#### Multiple Commands

It is possible to send several commands in one. It is important to send these commands with **LV01| .... |LX02** to enclose them.

```javascript
let result = await app.businessFunction({
  //Common Parameters for all functions
  functionName: "BizerbaSoap",
  methodName: "SendMessage",
  silentMode: false, //false is default. If set to true, the Gebra Suite will not show an error message box. it is up to you to inform the user.
  
  url: "192.168.0.54", //The URL of Bizerba WebAPI
  device: "GLPmaxx", //Device to be addressed
  message: "A!LV01|GD02|lb;-3;222|GD10|USD;-2;333|LX02" //BxNet command
  timeout: 15 //Timeout in seconds for the request
});
```

#### Multiple Commands as an object array

In this case the control characters LV01| .... |LX02 are not necessary.

```javascript
let result = await app.businessFunction({
  //Common Parameters for all functions
  functionName: "BizerbaSoap",
  methodName: "SendMessage",
  silentMode: false, //false is default. If set to true, the Gebra Suite will not show an error message box. it is up to you to inform the user.
  
  url: "192.168.0.54", //The URL of Bizerba WebAPI
  device: "GLPmaxx", //Device to be addressed
  message: [{
    "GD02": "lb;-3;222", 
    "GD10": "USD;-2;333"
    }], //BxNet command
  timeout: 15 //Timeout in seconds for the request
});
```

#### Multiple Commands directly from a sqlRead result

In this case the control characters LV01| .... |LX02 are not necessary.

<pre class="language-javascript"><code class="lang-javascript"><strong>let bizerbaMessage = app.sqlRead("bizerbaMessageForItem", {itemId: 4711});
</strong>
<strong>let result = await app.businessFunction({
</strong>  //Common Parameters for all functions
  functionName: "BizerbaSoap",
  methodName: "SendMessage",
  silentMode: false, //false is default. If set to true, the Gebra Suite will not show an error message box. it is up to you to inform the user.
  
  url: "192.168.0.54", //The URL of Bizerba WebAPI
  device: "GLPmaxx", //Device to be addressed
  message: bizerbaMessage, //BxNet command
  timeout: 15 //Timeout in seconds for the request
});
</code></pre>

### Example Response

```json
//This response has no follow up -> status = OK
{
  "handle": "",
  "response": "Q|A|G|D|12042023|T|16:09:23:666.16|H|1",
  "status": "OK"
}
```

```json
//This response has a follow up -> status = Next
//The response code can be used with the function ReceiveMessage
{
  "handle": "",
  "response": "Q|A|G|D|12042023|T|16:09:23:666.16|H|1",
  "status": "Next"
}
```
