In order to learn more about it click here.

Database

In this folder, Brixxbox provides you all the functionality which is needed to create, update and maintain your database. Following are the sub options provided by Brixxbox to manage database.

Info

All the metadata information about users database is provided under this option. For example, name of database, creation date and available space etc. A snippet of an example database's info is given below:

Tables

Tables option provides user with searching, creating, editing, and exporting different data tables present in the database. It provides a detailed list of all the tables present. An example of tables present is listed below:

Sql Statements

Brixxbox allows users to create sql statements regarding their app's usability and save them. This option provides functionality to create, edit, and delete sql statements. It also lists all the present sql statements. In order to know more about managing them click here.

Sql Procedures

This option allows you to maintain SQL stored procedures for your Brixxbox Database. stored procedure is a prepared SQL code that you can save, so the code can be reused over and over again. It allows users with functionality to create, edit, and delete stored procedures. In order to learn more about it click here.

Sql Functions

Brixxbox allows users to write, edit, delete Sql functions. User only have to provide the body of a function, the function will be generated from it. In order to learn more about it click here. In order to learn more about it click here.

Sql Triggers

Triggers are such functions which run or get triggered when a certain event occurs. In this app, Brixxbox allows you to maintain DML triggers for your database tables. In order to learn more about it click here.

Data sources

Brixxbox allow users to work with new data sources using this option. It allows you add, update, and delete new data sources. Keep in mind that these data sources are different from the database option which is explained above.

Reports


Reports

In Brixxbox, user is able to add new reports. Brixxbox allows you to add html elements in your reports. This gives user to add anything to report page with respect to their needs. Brixxbox also allow user to install "telerik" report designer. It helps users to build, edit, and view reports. An simple example of a report is a "customerofferreport". A snapshot of example is given below for reference.

In order to learn more about reports click here.

Custom messages

In this app, Brixxbox allows you to add custom messages. These messages can be used to portray warning, success or error state. For example, In case of successful order placement, we can show a thank you method to our user. In order to learn more about it click here.

Server Functions

Brixxbox is composed of maninly two parts: a javascript engine which works works in the browser, and web services which are present on server side. These are mainly used to get and post calls to web api's requests. On the front end, you can use "serverFunction" api in custom code to call different functions along with their parameters. Here is an example usage of serverFunction api.

javascript
let functionResponse = brixxApi.serverFunction("myFunction", {
   name: "Hallo"
});
console.log(functionResponse.functionResult);

In order to learn more about server functions click here.

Job Schedule

Brixxbox allows userss to automate their tasks which they want to perform on regular interval basis by using app job schedular. This minimizes user effort. For example, User want to update manager about current status of work on regular basis. One way is to do perform this task manually each day or user can simply use Brixxbox job schedular to automate this task once and for all. In order to learn more about App job click here.

Translations

This app provides functionality of logging messages that need top be translated from one language to another. For example you want to thank user after successfully placing an order. In order to learn more about App job click here.

Files

Brixxbox allows users to upload files from outside and it also stores files generated by different app in the workspace. There are 19 deiiferent types of documents are allowed in Brixxbox uptil now. In order to learn more about files or attachments click here

Document types


Document types

Brixxbox allows users to add different tpyes of documents in their workspace. In Brixxbox, each document is assigned a specific type for example invoice, list, bild etc. Document types lets you categorize attachments of anytype. The main properties of any attachemnt in Brixxbox are type id and name of document type. Document type is editable afterwards but id is not. In order to learn more about document type click here.

User Dashboards

This panel is used to configure which apps will be started for each user and role, when the user opens the their Brixxbox workspace. This app provides easy access to important applications without or little navigation. They enable your to become more productive. In order to learn more about document type click here.


description: Downloads a list of attachment ids as a zip file.

downloadAttachments

Parameters

downloadOptions - JSON object

requestedIds - list of ids to download

fileName - (optional) name of the downloaded file

Example Usages

javascript
   brixxApi.downloadAttachments({
      requestedIds:[196, 197, 200]
   });

javascript
   brixxApi.downloadAttachments({
      requestedIds:[196, 197, 200],
      fileName: "myDownload.zip"
   });


description: Deletes an attachment and its link to a record.

deleteAttachment

Parameters

attachmentId - the id of the attachment you want to delete

Example Usages

javascript
   brixxApi.deleteAttachment(42);


description: >-
  Disables (or enables) the hyperlinks in grid cells, automatically generated
  for combo box controls. This function also refreshes the grid.

disableGridHyperLinks

Parameters

controlId - The id of the grid control

disable - true, if you want to disable the hyperlinks, false if you want to enable them again.

Example Usages

javascript
   brixxApi.disableGridHyperLinks("myGrid", true); //disable links
   brixxApi.disableGridHyperLinks("myGrid", false); //enable links again


cloudQuery

Requests Data from a CloudGateway Enpoint

Parameters

```
{
    AppName: "MyCloudGateway", //The Name in the ApiKey List
    Endpoint: "LocalFirebird", // Configured Endpoint
    SqlStatementId: "fbGetAddress", //Optional statemnt id, depending on the Plugin
    Parameters: { //Optional Parameters
      "id": 1
    },

}
```

Example Usages

Query an address from a firebird database

```javascript
   brixxApi.cloudQuery({
    AppName: "MyCloudGateway",
    Endpoint: "LocalFirebird",
    SqlStatementId: "fbGetAddress",
    Parameters: {
      "id": 1
    },

})
```


description: Changes an existing help text for a control at runtime.

changeHelpText

Parameters

controlId => Id of the control

helpText => the new text, you want to set or empty to remove an existing text

Example Usages

javascript
   brixxApi.changeHelpText("myControl", "Hello World");


description: >-
  (Beta) Cancels the drag or edit operation that triggered the OnEventChange
  event and moves all events back to their origin position. Must be used inside
  the OnEventChange event.

cancelCalendarChanges

Parameters

controlId - The id of the calendar control

Example Usages

javascript
    brixxApi.cancelCalendarChanges("myCalendar");


Functions


displayRecord

Displays a record in an brixxbox app. To get a record, you could use e.g. loadRecord

Parameters

the record.

the current control. This control is excluded from the discard changes check, that occurs before the record is displayed

Example Usages

Simple (pay attention to the await keyword)

javascript
   await brixxApi.displayRecord(myRecord, "myKeyControlId");


description: (Beta) Adds an event source object to the calendar

addCalendarEventSource

Parameters

controlId - The id of the calendar control

eventSource - the Event source object

Example Usages

javascript
   app.addCalendarEventSource("myCal", {
      events: [
         {
            title: 'Sammple Event 1',
            start: '2020-12-08',
         },
         {
            title: 'Sammple Event 2',
            start: '2020-12-10',
         },
      ],
      id: 1,
      color: 'yellow',   // an option!
      textColor: 'black' // an option!
   });


copyConfigRecordById

Creates a deep copy from a config record. Typical example is to create a copy of an "order" record, with a copy of all the "orderLines" from that source "order". brixxbox will use the "Cascade Copy" flag of a grid control, to decide if which referenced records will be copied.

Parameters

configName

recordId - the id of the source record

additionalValues - json object of values in the target record that should be modified. e.g. an "orderDate" field. Can be null, in this case you get a 1:1 copy except the record id.

Example Usages

Exact copy:

javascript
   let newOrder = brixxApi.copyConfigRecordById("customerOrder", 1376);

Copy with new date for header data and manipulating two columns of line item data:

javascript
   let newOrder = brixxApi.copyConfigRecordById("customerOrder", 1376, {
      cordOrderDate: new Date(),
      cordlnOrderQuantity: "1",
      cordlnDeliveredQuantity: null
   });


description: Add Toolbar Buttons with different functionalities.

addToolbarButton

As we have already discussed in documentation of SetToolbarButtonMode. These are several buttons that are provided by Brixxbox for each app like adding new record, saving new record etc. These buttons provides general functionality needed by most of the apps but in case your app needs extra functionality, Brixxbox also allows this. It is provided by brixxApi function addToolbarButton. It takes a JSON object as a parameter. This JSON contains all the properties that defines this custom button as well as the functionality provided by it. The properties include name, id, and function to execute on clicking this button etc. Adds a custom button to the app toolbar.

Example

javascript
   brixxApi.addToolbarButton({
            title: "Print Invoice",
            icon: "print",
            id: "printInvoiceToolbarButton",
            onclick: async function () {
                brixxApi.triggerEvent("click", "printInvoiceBtn");
            }
        });

Parameters

toolbarButtonOptions - It is a JSON Object. In JSON object we passes parameters in the form of key value arguments.It include properties like name, id, function, etc.

Example Usages

As we have already seen a minimal custom print button in above example. Lets now add extra properties like group, css class, and shortcut for our print button. Now we also want this button to be added in our app toolbar on initialization. For this purpose goto current app properties and add onAppInitialized event. Now we need to add following code as a custom code to this event.

javascript
   brixxApi.addToolbarButton({
            title: "Print Invoice",
            icon: "print",
            text: "Rechnung drucken",
            group: "invoice",
            id: "printInvoiceToolbarButton",
            cssClass: "btn-success",
            onclick: async function () {
                brixxApi.triggerEvent("click", "printInvoiceBtn");
            },
            shortcut: "Ctrl-Alt-P"
        });

Now when our app is initialized, we can see our custom button on the app toolbar and it should look like this.

We can also add different custom buttons to our app depending upon our own requirements.


description: Deletes a record of a given config

deleteConfigRecordById

Parameters

configName - the name of the config

id - the record id you want to delete

Example Usages

javascript
   brixxApi.deleteConfigRecordById("address", 123);


description: >-
  Creates an url, that leads to a standalone app for pulic use. There is still a
  valid user logged in. The public user has to be configured in the settings as
  a "valid external user" for security reason

createPublicAppUrl

Parameters

options - Json object with the same properties as [createPublicAppUrl](/globalDoc/function_createPublicAppUrl) options, plus:

publicUser - the user email address of the brixxbox user, that will be used for the public app .

Example Usages

javascript
   await brixxApi.createPublicAppUrl({appName: "survey", publicUser: "surveyuser@acme.com", id:1});


description: >-
  Calls a webhook to trigger a system to do anything like posting a message to a
  teams channel.

callWebHook

Parameters

url - The url of the teams or slack channel, see the video to learn how to get a WebHook url.

{% embed url="https://youtu.be/HhvS3Gbuaxg" %}

2. the message you want to send. That depends on the service, you want to post to. here are some examples for Microsoft Teams(https://docs.microsoft.com/de-de/microsoftteams/platform/webhooks-and-connectors/how-to/connectors-using), but it can be as easy as seen in exampel 1

Example Usages

Plain text message

javascript
   brixxApi.callWebHook(myUrl, {
      text: "Hello World"
   });

full styled message with actions


full styled message with actions

javascript
   brixxApi.callWebHook(myUrl, {
      "@type": "MessageCard",
      "@context": "http://schema.org/extensions",
      "themeColor": "006E7E",
      "summary": "A new message from brixxbox",
      "sections": [{
         "activityTitle": "![TestImage](https://47a92947.ngrok.io/Content/Images/default.png)A new message from brixxbox",
         "activitySubtitle": "Volkers Sandbox",
         "activityImage": "https://teamsnodesample.azurewebsites.net/static/img/image5.png",
         "facts": [{
            "name": "Assigned to",
            "value": app.userId
        }],
        "markdown": true
      }],
      "potentialAction": [{
         "@type": "ActionCard",
         "name": "Add a comment",
         "inputs": [{
            "@type": "TextInput",
            "id": "comment",
            "isMultiline": false,
            "title": "Add a comment here for this task"
        }],
        "actions": [{
            "@type": "HttpPOST",
            "name": "Add comment",
            "target": "http://..."
        }]
      }, {
        "@type": "ActionCard",
        "name": "Set due date",
        "inputs": [{
            "@type": "DateInput",
            "id": "dueDate",
            "title": "Enter a due date for this task"
        }],
        "actions": [{
            "@type": "HttpPOST",
            "name": "Save",
            "target": "http://..."
        }]
      }, {
        "@type": "ActionCard",
        "name": "Change status",
        "inputs": [{
            "@type": "MultichoiceInput",
            "id": "list",
            "title": "Select a status",
            "isMultiSelect": "false",
            "choices": [{
                "display": "In Progress",
                "value": "1"
            }, {
                "display": "Active",
                "value": "2"
            }, {
                "display": "Closed",
                "value": "3"
            }]
        }],
        "actions": [{
            "@type": "HttpPOST",
            "name": "Save",
            "target": "http://..."
        }]
      }]
   });


description: >-
  Creates a report on the Server and retrieves it to the client. The only
  format, currently supported is pdf.

createReport

Parameters

reportControlId - the id of the reportControl in your app. This can be invisible, if you don't need a preview.

createOptions - JSON Object with options

print - (bool, default = false) if set to true, this will trigger the print dialog after the report is create.

archive - (bool, default = false) if set to true, the report is saved as an attachment to the current record,

saveFile - if set. the report will be downloaded with a generic file name (brixxbox-print.pdf), except, if saveFileName is set.#

saveFileName - if set. the report will be downloaded with that file name.

reportId - (optional) if defined, this will overruled the reportId given for the control in the config editor. This is not the controlId, but the id (name) of the report definition

cloudPrinter - (optional) the created report will be send to the cloud printer right after creation.

Like a on a dataRequest, all controls of the current app will bo automatically send as report parameters, plus the recordId of the current record as "id", even if you dont have a control "id" in your app.

Example Usages

javascript
   brixxApi.createReport("invoiceReport", {print: true}); //will create the invoiceReport as a pdf and prints it on the client side

javascript
   brixxApi.createReport("invoiceReport", {
      print: true,
      archive: true,
      documentTypeId: 1,
      saveFileName: "myPrint.pdf"
   });
   //will create the invoiceReport as a pdf and prints it on the client side, it will also save the pdf as an attachment to the current record.

javascript
   brixxApi.createReport("invoiceReport", {
      print: true,
      reportId: "invoiceReportSimple"
   });
   //In this case, we choose a different reportId

Create a report and send it to a cloud printer

javascript
   brixxApi.createReport("invoiceReport", {
      cloudPrinter: "HP LaserJet",
   });


cloudPrint

Sends a PDF to a printer, that is connected by the BrixxboxCloudGateway. You can sent a document to a cloudprinter by using createReport as well

Parameters

A json object

Example Usages

Print an existing attachment

javascript
   brixxApi.cloudPrint({
      printerName: "HP LaserJet", //Printer NAme
      attachmentId: "1", //Attachment id
   });

Print an existing attachment with multiple copies

javascript
   brixxApi.cloudPrint({
      printerName: "HP LaserJet",
      attachmentId: "1",
      copies: 5 // 1 copy is the default. Needs "cloudPrint Gateway" installer Version 1.0.1 or newer
   });

Print a new created report without archiving

javascript
   let myReport = await brixxApi.createReport("myReport");
   brixxApi.cloudPrint({
      printerName: "HP LaserJet", //Printer NAme
      blob: myReport, //The report blob object
   });


description: >-
  If the current brixxbox app is startet in a modal window, that window will be
  closed.

closeModal

Example Usages

javascript
   brixxApi.closeModal();


description: Adds an Event Listener to the brixxbox or one of its controls

addEventListener

Parameters

Events

Control Id (optional)

If the event is control specific (e.g. click on a buttton), this has to be the control id of that button

Function

The code that should be executed in case of this event

The first parameter is the brixxApi

Example Usages

javascript
   brixxApi.addEventListener("onRecordSaved", function (brixxApi, eventArgs) {
      alert("Record saved in " + brixxApi.appName);
   });

javascript
   brixxApi.addEventListener("onClick", "myButton", function (/*event parameters are optional*/) {
      alert("Button clicked");
   });


description: Deletes a record from the database.

deleteRecord

Parameters

options - json object

id - the record id. Optional. By default, this is the current record id. (The current record id can be accessed here: brixxApi.actualRecordId)

noConfirmMessage - Optional. By default, this is false. If set to true, you will not get a confirm MessageBox. the record will be deleted.

Example Usages

1. Simple

javascript
   brixxApi.deleteRecord(); //deletes the current displayed record
   brixxApi.deleteRecord({id: brixxApi.actualRecordId}); //deletes the current displayed record

2. Simple - No Confirmation

javascript
   brixxApi.deleteRecord({noConfirmMessage: true}); //deletes the current displayed record without confirmation

3. Without displaying the record

javascript
   let myRecord = await brixxApi.laodRecord("myKeyControl"); loads a record into myRecord
   brixxApi.deleteRecord({id: myRecord.id}); //deletes the loadedRecord


description: Unselects all rows of a data grid.

clearGridSelection

Parameters

controlId - id of the grid control

Example Usages

javascript
   brixxApi.clearGridSelection(myGrid);


--
description: Shows the email compose Dialog, or sends an email without an interface popup.
---

# composeEmail

### Parameters

1. emailOptions - (optional) Json object with email parameters.
   * to - array of email addresses
   * cc - array of email addresses
   * bcc - array of email addresses
   * text - message text
   * subject - subject
   * from - single string with an email address
   * replyTo - single email, that will be used as to reply to
   * autoSend - if set to true, the mail will be send automatically. You will not see a dialog at all. (Default is false)
   * hideToEmail - if set to true. The recipients email address is hidden in the email dialog
   * attachmentIds - an array of attachment ids that will be sent as an attachment,
   * attachmentBlobs - an array of blobs objects that will be sent as an attachment, {name: myFileName, blob: myBlob}
   * recordId - RecordId if you would like to attach the email to an record. If empty, this is the current record Id (available from 18.11.2021)
   * appName - AppName if you would like to attach the email to an record. If empty, this is the current App Name (available from 18.11.2021)

### Example Usages

#### Example 1

Shows the dialog without any predefined values

Shows the dialog text and to addresses

```javascript
   composeEmail({
      text: `This is the messsage text and this is a link: www.brixxbox.net`,
      to:["john.doe@acme.com", "jane.doe@acme.com"],
      subject: "This is the mail subject",
      from: "noreply@acme.com"
   });
```

#### Example 2

Sends the email without a dialog

```javascript
   composeEmail({
      text: "This is the messsage text",
      to:["john.doe@acme.com", "jane.doe@acme.com"],
      subject: "This is the mail subject",
      from: "noreply@acme.com",
      replyTo: "reply@acmy.com",
      autoSend: true //Set this to avoid the dialog
   });
```


#### Example 3 - attachment blobs

```javascript
   composeEmail({
      text: "This is the messsage text",
      to:["john.doe@acme.com", "jane.doe@acme.com"],
      subject: "This is the mail subject",
      from: "noreply@acme.com",
      autoSend: true,
      attachmentBlobs: [
         {
            name: "Test1.pdf",
            blob: app.createReport("report")
         },
         {
            name: "Test2.pdf",
            blob: app.getAttachmentById(2)
         }
      ],
   });
```

#### Example 4 - attachment ids

```javascript
   composeEmail({
      text: "This is the messsage text",
      to:["john.doe@acme.com", "jane.doe@acme.com"],
      subject: "This is the mail subject",
      from: "noreply@acme.com",
      autoSend: true,
      attachmentIds: [1, 2, 3]
   });
```


description: This function is used to color a single cell in a grid, or highlight it.

addClassToGridRowCell

Parameters

eventParameter - this is the special parameter you get in OnRowCreated

columnId - the name (id) of the column

className - the classnaem to set

Example Usages

Example inside OnRowCreated

javascript
   brixxApi.addClassToGridRowCell(eventArgs, "cordlnShippedQuantity", "success");


description: >-
  Returns the geo location and additional information like speed and altitude if
  available. Be aware, that this is an asynchronous function and you have to use
  await.

getGeoLocation

The Result looks like this:

coords
      accuracy: 33
      altitude: null
      altitudeAccuracy: null
      heading: null
      latitude: 51.073834399999996
      longitude: 6.0768204
      speed: null
   timestamp: 1557477072518

Example Usages

javascript
   let myGeoLocation = await brixxApi.getGeoLocation();
   console.log(myGeoLocation.coords.latitude);
   console.log(myGeoLocation.coords.longitude);

To Visualize a geo location in google maps, see this documentation(http://www.joerg-buchwitz.de/temp/googlemapssyntax.htm) for possible url parameters, You could use the following commands in an event:

javascript
   let myLocation = await brixxApi.getGeoLocation();
   window.open("http://maps.google.de/maps?q=" + myLocation.coords.latitude + "," + myLocation.coords.longitude,'_blank');


description: Refreshes the attachment grid in the sidebar if it is visible

refreshAttachments

Example Usages

javascript
   brixxApi.refreshAttachments();


getSessionToken

GUID stands for Global Unique Identifier. A GUID is a 128-bit integer (16 bytes) that you can use for authentication purposes. We use this token to identify a user for same browser session. This function can be used to get GUID for current user sessions. It can then be used to authenticate user between different apps. Another usecase is that it could be used to identify a shopping cart. An important aspect here to note is that when when you close all browser tabs and start the Brixxbox again, this token will be different.

Example Usages

An example user is that user can get access tokens using this getSessionToken functions from two apps and compare them to confirm user identity i.e after login this can be used as authenticate the user.

javascript
   let myToken = brixxApi.getSessionToken();


description: Initializes a control to its empty state

initControl

Example Usages

javascript
   brixxApi.initControl();


description: >-
  Returns a list of all the attachments of the current record. The list is
  ordereb by id desc. so the newest documents will be the first you will find
  while iterating over the array.

getAttachmentsForCurrentRecord

Example Usages

Example 1

console.log(brixxApi.getAttachmentsForCurrentRecord());

Example 2 Filtering

javascript
   let allAttachmentsForThisRecord = brixxApi.getAttachmentsForCurrentRecord();
   let invoices = allAttachmentsForThisRecord.filter(singleAttachment => {return singleAttachment.documentTypeId == 2}); //We assume, that there is just one invoice
   let attachmentBlob = brixxApi.getAttachmentById(invoices[0].id);
   brixxApi.printBlob(attachmentBlob)


description: Determens if the current brixxbox app is started in a modal window.

isModal

Example Usages

Simple

javascript
   if(brixxApi.isModal()){
      alert("the brixxbox app is modal!");
   }


description: >-
  Prints a document that is a blob. You might get a blob by requesting an
  attachmen

printBlob

Parameters

Print Document

Example Usages

javascript
   brixxApi.printBlob(brixxApi.getAttachmentByFileName("Invoice1.pdf"));


localValue

Stores and retrieves local values, like settings or something, that you want to have persistent on this specific browser. The value will be saved only for the browser you are currently working on. The value will be save in the scope of the current workspace you are working in.

Parameters

key - Key name

value - (optional) value you want to save. If this is empty, brixxbox will return the value, you saved before.

This is not an asynchronous operation. No await needed!

Example Usages

```javascript
   brixxApi.localValue("myKey", "Hello World"); //Save the value "Hello World" under the key "myKey"
   let x = brixxApi.localValue("myKey"); //Retrieve the Key "myKey". This will result in "Hello World"

console.log(x)
```


description: Executes a stored procedure.

executeStoredProcedure

Parameters

procedureName - The name of the stored procedure

procedure parameters - If you need to add parameters, you can use this json object to set them

queryOptions - (optional) a json object with options for the request

timeout - (optional) timeout for the SQL Request. Default is 30 seconds

connectionKey - (optional) a key to a custom settings entry with the connection string to an external MSSQL database

Example Usages

1. Simple (pay attention to the await keyword)

javascript
   await brixxApi.executeStoredProcedure("procedureName");

2. With parameters (pay attention to the await keyword)

javascript
   let parameterJson = {
      myCustomSqlParameter: 12345
   };
   await brixxApi.executeStoredProcedure("procedureName", parameterJson);

3. Short version (pay attention to the await keyword)

javascript
   await brixxApi.executeStoredProcedure("procedureName", {
      myCustomSqlParameter: 12345
   });

4. With Timeout

javascript
   await brixxApi.executeStoredProcedure("procedureName", {
      myCustomSqlParameter: 12345
   },{
      timeout: 45
   });


description: Gets and attachment by its unique id.

getAttachmentById

Parameters

id - id of the attachment

Example Usages

javascript
   brixxApi.getAttachmentById(1234);

javascript
   let allAttachmentsForThisRecord = brixxApi.getAttachmentsForCurrentRecord();
   let invoices = allAttachmentsForThisRecord.filter(singleAttachment => {return singleAttachment.documentTypeId == 2}); //We assume, that there is just one invoice
   let attachmentBlob = brixxApi.getAttachmentById(invoices[0].id);
   brixxApi.printBlob(attachmentBlob)


description: >-
  Sets the cursor focus to a specific control and optionally selects the
  existing text.

setFocus

Parameters

controlId - the name of the control to set the focus to

select - (optional) if set to true, the existing text in the control is selected. if empty or false, the cursor is placed behind the not selected text

Example Usages

javascript
   brixxApi.setFocus("adrName"); //set focus and palce cursor after existing text
   brixxApi.setFocus("adrName", true); //set focus and select the existing text


description: >-
  Converts a date to the total days since 1.1.1970 to make it easy comparable.
  You can use Date, or DateTime as input and even if two datetime values do have
  different times.

getCalcDate

Parameters

inputDate - This can be a date or datetime in any format or a controlId to a date or dateTime control

Example Usages

javascript
   let calcDate1 = brixxApi.getCalcDate(brixxApi.getFieldValue("myDateTime1"));
   let calcDate2 = brixxApi.getCalcDate(brixxApi.getFieldValue("myDate2"));
   if(calcDate1 === calcDate2){
      //Do something
   }

Example Results

javascript
   brixxApi.getCalcDate(new Date('1995-12-17 03:24:00')) //9481 (days since 1.1.1970)
   brixxApi.getCalcDate('1995-12-17 03:24:00')           //9481
   brixxApi.getCalcDate('1995-12-17 12:44:30')           //9481
   brixxApi.getCalcDate(myControlId)                     //?


description: Enables or disables a specific control.

setEnable

Parameters

controlId - id of the brixxbox control as a string

enable - (optional, default = true) bool value if the control should be enabled or not

subControl (optional) Some controls have sub Controls, that can be enabled or disabled. Important: setEnable for subcontrols cannot be used in onAppStart, because some controls are not fully created at that time, use onAppInitialized instead. Here is a list of possible subControls:

grids
inline - enables or disables the inline editing of a grid (Cell Editing)
buttons - enables or disables the buttons of a grid
buttonNew - enables or disables the new buttons of a grid
buttonDelete - enables or disables the delete buttons of a grid
buttonCopy - enables or disables the copy buttons of a grid

Example Usages

1. Simple

javascript
   brixxApi.setEnable("myControlId"); //enables the control
   brixxApi.setEnable("myControlId", true); //enables the control
   brixxApi.setEnable("myControlId", false); //disables the control

2. Disable the Grid inline edit feature

javascript
   brixxApi.setEnable("myGridControl", false, "inline");

3. Disable all data manipulating grid Toolbar Buttons

javascript
   brixxApi.setEnable("myGridControl", false, "buttons");

4. Disable a single grid Toolbar Buttons

javascript
   brixxApi.setEnable("myGridControl", false, "buttonNew");
   brixxApi.setEnable("myGridControl", false, "buttonDelete");
   brixxApi.setEnable("myGridControl", false, "buttonCopy");


loadRecord

Loads a record, based on the current config, from brixxbox server and returns a promise. This is a async function. You have to await the result, if you want to use it. This function will not display the record, it will just load and return it. To display the record, use the function result with displayRecord.

Parameters

The first parameter is a control with the key value, that will be used to find the record (like an address number)

Example Usages

Simple (pay attention to the await keyword)

javascript
   let myRecord = await brixxApi.loadRecord("myKeyControl");


description: Gets the html element for this brixxbox control.

getHtmlElement

Note: Usually it is not necessary to get the Html element itself. Make sure there is no better way to do the things you want to do by using the brixxApi functions!

Example Usages

javascript
   let myField = brixxApi.getHtmlElement("myFieldId");
   myField.disabled = true; // just for demonstration. Please use brixxApi.setFieldEnable("myFieldId", false) instead


description: Saves the changes to the current record in the database.

saveCurrentRecord

Example Usages

Simple (pay attention to the await keyword)

javascript
   await brixxApi.saveCurrentRecord();


description: >-
  Resets all validators of an app to their default state. So you don't have to
  bother with enableValidator to reset them or what the default state is.

reInitValidation

Example Usages

javascript
   brixxApi.reInitValidation();


description: Add or set a unit in front of a numeric or text field.

setFieldUnit

Parameters

controlId - Id of the control

The string value of the unit you want to set. If this parameter is not set, the unit will be removed.

Example Usages

Simple textbox

javascript
   brixxApi.setFieldUnit("myControlId", "â¬");

Remove unit

javascript
   brixxApi.setFieldUnit("myControlId");


description: >-
  Reloads the content of a single control (like combobox or grid) or of all such
  controls in an brixxbox application.

refresh

Parameters

Optional. A control, if you want to refresh just this control, or undefined to refresh all controls within an application.

Example Usages

1. Simple (pay attention to the **[await](/globalDoc/glossary_await)** keyword)

javascript
   await brixxApi.refresh("myKeyControl");
   await brixxApi.refresh();


description: >-
  It can set the whole brixxbox app or some controls depending upon the use case
  which is required, in a readonly mode. All Input fields, save- new- and delete
  toolbar buttons are disabled.

readOnlyMode

In Brixxbox, we have certain types of users like system users those who build the system, users those who will use the system, and admins, they will manage the systems etc. Each user should have different access to the system. It means all acess rights should only be given to admin users. Lets suppose we have an orders app and recorded orders. System users should only be allowed to fetch and check orders while on the other hand admins shouls also be allowed to edit orders and make changes to them. This is this brixxApi readOnlyMode function comes into play.

Example

This code sets the whole app to read only mode. All the input controls and even the toolbar button get disabled.

Parameters

readOnlyMode function can be used with or without options. Following are the optional parameters:

readOnly - (bool, default = true) This indicates if the readOnly mode is enabled (true) or disabled (false). If it is set to true or without options, it disables the whole app. If set to false, the app starts to behave normally. Every control and each toolbar button is enabled.

options - It is a JSON object which can be passed as an additional options.

exclude - It is an array of controlIds that should be excluded from the disable functionality of readOnlyMode function.

Example Usages

We can use this "readOnlyMode" function with or without options. Lets see both of them in action.

Without options

To disable each and every control and toolbar buttons use this function without any options like

javascript
   brixxApi.readOnlyMode(); // This will set app in readOnly Mode.
   brixxApi.readOnlyMode(true); // This will also set complete app in readOnly Mode.

In order to enable all the controls, set the readOnlyMode function with false value of readOnly parameter. It will enable back all the controls and the app will start behaving normally.

javascript
   brixxApi.readOnlyMode(false); // sets back to normal Mode.

With options


javascript
   brixxApi.readOnlyMode(false); // sets back to normal Mode.

With options

Now if we dont want to use default functionality of disabling or enabling the whole app, we can usereadOnlyMode options to enable or disable some of the controls. Lets say we want to disable 2 controls from an app then we have to pass the name sof these controls in exclude option array like

javascript
   brixxApi.readOnlyMode(true, {
      exclude: ["myFrstControl", "mySecondControl"]
   });

Example in Action

Lets say we have address app and we want to disable all of it. It can be done in different ways. For a moment, lets stick to "appInitialized" event. Add this function as a custom code of "appInitialized" event and save the app. It will look like this

As we can see each control as well as app toolbar is also disabled.


getUserClaim

Brixxapi allows user to set a claim value. This claim Value gets added when user gets logged in. It is used to identify users claim. For example, to check whether a user is someone who he claims to be or not. By using this function, we can get userClaim and make useful comparisons in our apps.

Parameters

claimName - This is the only paramter this function takes. It is the claiName which should be in the form of string.. Brixxapi allows user to add claim name with or with out "claim_" prefix.

Example

Let suppose we have a claimName parameter "EFitDealer" then Brixxapi will consider both "EFitDealer" and "claim_EFitDealer" as same.

Example Usages

We can use "getUserClaim" function to get user's claim, a way to check user identity. As a parameter, we need to provide the claimName to this function. We can provide only the claimName or the claimName plus "claim_" as prefix. Lets see both of them in action. We have a claimName "EfitDealerNumber", now we want to get userClaim:

Lets first do it without prefix "claim_".

javascript
   let dealerNumber = brixxApi.getUserClaim("EfitDealerNumber");
   console.log("The dealer Number is: " + dealerNumber);

It is ame as the previous example but now we use prefix.

javascript
   let dealerNumber = brixxApi.getUserClaim("claim_EfitDealerNumber");
   console.log("The dealer Number is: " + dealerNumber);

An important thing to notice here is that it is required by Brixxbox that for using SQL Parameters for claims must have to start with the "claim_" prefix.

For example, Userclaims can also be used as SQL parameters:

sql
   select @claim_EfitDealerNumber


description: >-
  Returns a custom message from the message manager. It replaces possibly passed
  parameters in the message. The target language can also be set.

getCustomMessage

Example Usages

javascript
   let msg = brixxApi.getCustomMessage("messageName", {"param1": "text1", "param2": "text2"}, "en-Us");
   brixxApi.setFieldValue("controlId", msg);


description: Returns an id of an attachment of a record in a config.

getConfigRecordAttachmentIdByFileName

Parameters

appName - the name of the config with the attachment

recordId - the id of the record with the attachment

fileName - the name of the requested attachment

Example Usages

javascript
   brixxApi.getConfigRecordAttachmentIdByFileName("customerOrder", 1234, "invoice.pdf");


loadAndDisplayRecordById

Loads a record, based on the value in the control, given as a parameter in the first argument and displays it. This function just combines loadRecordById and displayRecord displayRecord

Example Usages

Simple (pay attention to the await keyword)

```javascript
   let recordId = 123;
   brixxApi.loadAndDisplayRecordById(recordId);

await brixxApi.loadAndDisplayRecordById(recordId);
```


description: Selects all rows with a specific value in a data grid column.

selectGridRows

Parameters

controlId - control id of the grid

columnId - id of the column to compare the value with

value - if the row has this value in the column with "columnId", it will be selected

Example Usages

javascript
   brixxApi.selectGridRows("myGrid", "imeiNumber", 1234567);


description: >-
  Refreshes the content of a single control based on its DataSource (not the
  SubDataSource!). If outside parameters have changed, you can force the
  brixxbox to reload the content of that control.

refreshDataSource

Parameters

1. controlId - (optional) id of the control, that you want to reload. If this is empty, all controls with datasources are refreshed.

Example Usages

javascript
   brixxApi.refreshDataSource("myControlId"); //Refreshes just "myControlId"

javascript
   brixxApi.refreshDataSource(); //Refreshes all Controls with a DataSource in the app


description: Enables or disables field validator.

enableValidator

Parameters

controlId - The control id of the field

validatorName - the name of the validator

enable - enable (true=default) or disable (false) the validator

Example Usages

javascript
   brixxApi.enableValidator("firstName", "notEmpty", false); //disables the validation of notEmpty for the control firstName


description: Saves a record for a config

saveConfigRecord

configName - name of the app config

record - a record structure Json object (as it comes from loadConfigRecordById)

Example Usages

Simple:

javascript
let record = await brixxApi.loadConfigRecordById("myConfig", 1);
record.data.Name = "John Doe";
brixxApi.saveConfigRecord("myConfig", record);

\
Create a new record:

javascript
brixxApi.saveConfigRecord("myConfig", {
    data: {
        myFirstName: "John",
        myLastName: "Doe"
    }
});

Create a new record and use the result:

javascript
let newRecord = brixxApi.saveConfigRecord("myConfig", {
    data: {
        myFirstName: "John",
        myLastName: "Doe"
    }
});
console.log("New Record Id:" + newRecord.data.id);


description: >-
  Returns the id of an attachment of the current record by looking for the given
  file name.

getAttachmentId

Parameters

fileName - the name of the file

Example Usages

javascript
   brixxApi.getAttachmentId("Invoice1.pdf")


logAdd

The brixxbox offers a client-side event log. Events like save/delete record, data validation messages, internal events etc. will be logged. In addition, the log can be accessed through brixxApi. The log view is located in the side bar. It will be shown in an extra tab page (only if data is available). Per default only entries for the current brixxApi Object (and its children) will be visible.

Parameters

Parameters can be passed as a json object.

text: the actual log text. If this value is missing no entry will be generated.

context: This should be set to a plausible group-criteria (e.g. save for record saved. validate for data validation). This value can also be used to remove the complete group from the log (see example).

status: Status can have the following values info, success, warning, danger or error. The log entry will get its color set accordingly. danger and error are interchangeable.

info: Additional info can be set. If empty its value will reflect the app title of the brixxApi object.

recordId: If not passed as a parameter the value will be set to record-ID of the brixxApi object (brixxApi.record.id).

Example Usages

javascript
brixxApi.logAdd({context: "GroupCriteria", status: "info", text: "Lorem ipsum dolor sit amet, consectetur adipisici elit"})

To remove an existing context from the log for the current brixxApi object logReset is available:

javascript
brixxApi.logReset("GroupCriteria")


description: Prints a report

print

Parameters

controlId - ControlId of the report control, that you want to print

Example Usages

javascript
   brixxApi.print(invoiceReport);


description: Checks if a row in a grid is selected or not.

isRowSelected

Parameters

controlId - The id of the grid

line - This can be either a whole line from a "myGrid.allRows" call or a single id from a record.

Example Usages

javascript
   let result = brixxApi.isRowSelected("myGrid", myLine)

Used in a loop

javascript
   let allRows = app.getFieldValue("myGrid.allRows");
   for(let i = 0; i < allRows.length; i++){
      if(brixxApi.isRowSelected("myGrid", allRows[i])){
         console.log("This is selected: " + line.id);
      }
   }

Used with an id

let result = brixxApi.isRowSelected("myGrid", 123); //Checks if the line with the id 123 is selected.


globalSearch

This functions is used to trigger global search of the whole workspace. It only takes one parameter which is a search keyword. This function is directly used in the each Brixxbox workspace. User can find it in top right corner of each workspace page. It is a textbox accompanied by search button. User needs to enter a string in the global search field at the top of the screen and it will trigger the search function. It can be useful if you want to search for a scan result or anything within your workspace in seconds.

Parameters

searchTerm - It is of type string.

Example Usages

User can find this button on top right corner. It looks like this.

User can enter any keyword and it with return thespecific results. User can also use this function in their apps. For this user need to provide a search keyword and can use it to retreive data from the global workspace. If user want to search "address" the code will look like this

javascript
   brixxApi.globalSearch("address"); //triggers a search for "address" in global address space.


saveCurrentRecordWithoutEvents

Works exactly like saveCurrentRecord. Except, that it des not trigger any events (like close on save).

Example Usages

Simple (pay attention to the await keyword)

javascript
   await brixxApi.saveCurrentRecordWithoutEvents();


description: >-
  Removes all modification flags from the controls. After this call, the user
  will not get a "discard changes" message until another control is modified.

markAllControlsAsUnModified

Example Usages

javascript
   let value = brixxApi.markAllControlsAsUnModified();


description: >-
  It provides the functionality of excluding controls from being affected by the
  readOnlyMode.

excludeFromReadonly

Exaample

javascript
   brixxApi.excludeFromReadonly(["myFirstControl", "mySecondControl"]);

Parameters

Control array - It is a json array of control ids.

Example Usages

As we have seen in ReadOnlyMode the example of address app and how we disabled every control using it without options. Now let say we want "Address Number" and "Name" controls to stay enabled. For this purpose, we will need to add these controls to our excludeFromReadOnly function and put this code in appStart event.

javascript
   brixxApi.excludeFromReadonly(["adrNumber", "adrName"]);

As we can see in snapshot below Address number and name controls are editable after the app is started. We can use this functionality with any number of apps.


description: >-
  All users in any Brixxbox workspace shoyuld have been assigned a specific user
  role. isUserInRole takes a string argument role. On the basis of this role
  parameter, it determines whether a logged user

isUserInRole

javascript
   brixxApi.isUserInRole("Management");

Parameters

role - It is a string parameter. It is the name of logged in user role which needs to be checked.

Example Usage

We have seen address app in the docs of ReadOnlyMode function. Now we will build upon that functionality. In it we have used readOnlyMode function to disable all ap controls. Now we want tht if user is of admin role then all the controls should be enabled and disabled otherwise. For this we need to update our custom code. It should look like this.

javascript
if(brixxApi.isUserInRole("Admin")){
    brixxApi.readOnlyMode(false);
    console.log("raghib")
}
else{
    brixxApi.readOnlyMode();
}

Now If user 'raghib' has an admin role assigned to him then address app will be enabled for him and for all other non admin users. It will be disabled.


description: Retrieve a value for a specific custom setting.

getCustomSetting

Parameters

settingName - the key for the setting

Example Usages

javascript
   let settingValue = brixxApi.getCustomSetting("groupOne.setting1");
   console.log(settingValue);


description: Executes a stored procedure and returns the query result.

queryStoredProcedure

Parameters

procedureName - The name of the stored procedure

procedure parameters - If you need to add parameters, you can use this json object to set them

queryOptions - (optional) a json object with options for the request

timeout - (optional) timeout for the request. Default is 30 seconds

connectionKey - (optional) a key to a custom settings entry with the connection string to an external MSSQL database

Example Usages

1. Simple (pay attention to the await keyword)

javascript
   let myResult = await brixxApi.queryStoredProcedure("procedureName");

2. With parameters (pay attention to the await keyword)

javascript
   let parameterJson = {
      myCustomSqlParameter: 12345
   };
   let myResult = await brixxApi.queryStoredProcedure("procedureName", parameterJson);

3. Short version (pay attention to the await keyword)

javascript
   let myResult = await brixxApi.queryStoredProcedure("procedureName", {
      myCustomSqlParameter: 12345
   });

4. Using a timeout

javascript
   let myResult = await brixxApi.queryStoredProcedure("procedureName", {
      myCustomSqlParameter: 12345
   },{
      timeout: 45
   });


description: Sets the background color of a control.

setBackgroundColor

Parameters

controlId

colorName - use one of these: "default", "primary", "secondary", "success", "danger", "warning"

Example Usages

Set to warning

javascript
   brixxApi.setBackgroundColor("myControl", "warning");

Set to normal

javascript
   brixxApi.setBackgroundColor("myControl", "default");
   brixxApi.setBackgroundColor("myControl"); //"default" is "default" ;)


description: Gets the unmodified value of the control.

getControlUnmodifiedValue

Example Usages

javascript
   let unmodifiedCompareValue = brixxApi.getControlUnmodifiedValue("myControlId");


loadRecordById

Loads a record from brixxbox server and returns a promise. This is a async function. You have to await the result, if you want to use it. This function will not display the record, it will just load and return it. To display the record, use the function result with displayRecord.

Parameters

The first parameter is a record id

Example Usages

Simple (pay attention to the await keyword)

javascript
   let myRecordId = 123;
   let myRecord = await brixxApi.loadRecordById(myRecordId);


description: Initializes all controls within a brixxbox App to their empty states.

initAllControls

Example Usages

javascript
   brixxApi.initAllControls();


description: Retrieves the blob of an attachment from the attachments of the current record

getAttachmentByFileName

Parameters

fileName - the file name you are looking for

Example Usages

javascript
   brixxApi.getAttachmentByFileName("Invoice1.pdf")


description: Refreshes all Badges of an app at once.

refreshBadges

Example Usages

javascript
   brixxApi.refreshBadges();


description: Change the decimal digits of a numeric field.

setDecimalDigits

Parameters

controlId - Id of the control

The value of digits for the numeric field.

Example Usages

Set digits

javascript
   brixxApi.setDecimalDigits("myControlId", 3);


description: >-
  Returns the signature of a signature control as a png (default) or svg image
  blob.

getSignatureImageBlob

Parameters

controlId - The id of the signature control

type - optional, if not set, the function returns a png image. If set to "svg", the function returns a svg vector image.

Example Usages

javascript
   let myBlob = brixxApi.getSignatureImageBlob("mySignature"); //gets the blob as PNG

javascript
   let myBlob = brixxApi.getSignatureImageBlob("mySignature", "svg"); //gets the blob as SVG

javascript
   brixxApi.printBlob(brixxApi.getSignatureImageBlob("mySignature"));


getBrowserToken

Gets a GUID Token, that identifies the browser. This token will NOT be different, when you close all browser tabs and start the brixxbox again. But it will be different, when you delete the local storage for that url. You could use this to identify a shopping cart, for example.

Example Usages

javascript
   let myToken = brixxApi.getBrowserToken();

brixxApi.getSessionToken

GUID stands for Global Unique Identifier. A GUID is a 128-bit integer (16 bytes) that you can use for authentication purposes. There are many types of GUID tokens, one of them is browser token. We can use this token to identify a user for same browser because his token will NOT be different, when you close all browser tabs and start the Brixxbox again. But it will be different, when you delete the local storage for that url. This function can be used to get GUID for browser. It can then be used to keep user session open. Another usecase is that it could be used to identify a shopping cart. An important aspect here to note is that when when you close all browser tabs and start the Brixxbox again, this token will not be different.

Example Usages

An example user is that user can get access tokens using this getBrowserToken functions from two apps and compare them to confirm user identity i.e after login this can be used as authenticate the user between different browser sessions.


description: Sets the font style of a control.

setFontStyle

Parameters

controlId

fontStyle - use one of these: "italic", "normal"

Example Usages

Set to italic

javascript
   brixxApi.setFontStyle("myControl", "italic");

Set to normal

javascript
   brixxApi.setFontStyle("myControl", "normal");
   brixxApi.setFontStyle("myControl"); // you can skip param2 if you want to set back to normal


loadAndDisplayRecord

Loads a record, based on the value in the control, given as a parameter in the first argument and displays it. This function just combines loadRecord and displayRecord

Example Usages

Simple (pay attention to the await keyword)

javascript
   brixxApi.loadAndDisplayRecord(keyFieldID);

javascript
   await brixxApi.loadAndDisplayRecord(keyFieldID);


description: Gets a value to a specific field

getFieldValue

Parameters

controlId => String with the control id. Some controls (like Comboboxes) do have sub information. in that case the controlId is combined with a ".". e.g. comboBoxId.subcontrolId

Example Usages

javascript
   let myText = "Hello World!";
   brixxApi.setFieldValue("myControlId", myText);
   value = brixxApi.getFieldValue('fieldId');

javascript
   let myFieldId = 'fieldId';
   let value = brixxApi.getFieldValue(myFieldId);

javascript
   let itemId = brixxApi.getFieldValue('itemCombobox'); //like any other control
   let taxKeyId = brixxApi.getFieldValue('itemCombobox.itmTaxKeyId'); //get the itmTaxKeyId value of the selected entry in acomboBox
   let itemName = brixxApi.getFieldValue('itemCombobox.itmName');

javascript
   let taxKeyId = brixxApi.getFieldValue('itemList').itmTaxKeyId; //get the itmTaxKeyId value of the selected entry in a grid
   let allRowsFromMyGrid = brixxApi.getFieldValue('itemList.allRows'); //get an array of all rows in a grid

javascript
   let selectedRowsFromMyGrid = brixxApi.getFieldValue('itemList.selectedRows'); //get an array of all selected rows in a grid
   let unselectedRowsFromMyGrid = brixxApi.getFieldValue('itemList.unselectedRows'); //get an array of all unselected rows in a grid
   let myRowJsonObject = brixxApi.getFieldValue('itemList.clickedRow'); //get the clicked row as a json object (only valid in onRowClick and onCellClick events)
   let myCellValue = brixxApi.getFieldValue('itemList.clickedCell'); //get the clicked cells formatted value (only valid in onCellClick events)
   let myCellId = brixxApi.getFieldValue('itemList.clickedCellId'); //get the clicked cells id (only valid in onCellClick events)

javascript
   for(let i = 0; i < allRowsFromMyGrid.length; i++){
   console.log(allRowsFromMyGrid[i].itmTaxKeyId);
   }


description: Gets a DateTime as a compareable number with a given accuracy.

getCalcDateTime

Parameters

dateTime value or controlId

accuracy - "seconds" (default), "minutes" or "hours"

Example Usages

javascript
   brixxApi.getCalcDateTime(myDateTimeControl);
   brixxApi.getCalcDateTime(myDateTimeControl, "minutes");
   brixxApi.getCalcDateTime(myDateTimeControl, "hours");

Example 2 calculation

javascript
   let durationInSeconds = brixxApi.getCalcDateTime(myDateTimeEnd) - brixxApi.getCalcDateTime(myDateTimeStart);
   let durationInMinutes = brixxApi.getCalcDateTime(myDateTimeEnd, "minutes") - brixxApi.getCalcDateTime(myDateTimeStart, "minutes");
   let durationInHours = brixxApi.getCalcDateTime(myDateTimeEnd, "hours") - brixxApi.getCalcDateTime(myDateTimeStart, "hours");


Common Functions

inviteUser(string email)

This function takes a string as a parameter. This string should be an email address of a new user to whom admin of current workspace wants to invite. This function provides functionality of sending an email to a new user.

Example Usage

javascript
   var result = brixxApi.inviteUser("john.doe@acme.com");

In order to learn more about this function click here.


description: Logs the user out. The user has to go to the login screen again to get access.

logout

Example Usages

javascript
   brixxApi.logout();


description: Calls a server function and returns the result

serverFunction

{% embed url="https://youtu.be/9arAy_c2uI0" %}

Parameters

functionName - the configured name of the function in App_ServerSideFunction

functionsParameters - (optional) json object with function parameters. The will be available in the function under body.parameters

options - (optional) See examples. You can use the options to get the payload of the request or a postman example, instead of calling the function. Can be used to debug a function on your local machine

Example Usages

To call a function and get the response object:

javascript
let functionResponse = brixxApi.serverFunction("myFunction", {
   name: "Hallo"
});
console.log(functionResponse.functionResult);

\
To get an example payload based on the current app state:

javascript
let functionResponse = brixxApi.serverFunction("myFunction", {
   name: "Hallo"
},{
   payload: true
});
console.log(functionResponse.functionResult);

To get an example postman collection including the payload of the current app:

javascript
let functionResponse = brixxApi.serverFunction("myFunction", {
   name: "Hallo"
},{
   postman: true
});
console.log(functionResponse.functionResult);

To define your own server functions please check Server Api Reference


description: >-
  Loads a record of a specific app config from brixxbox server and returns a
  promise. This is a async function. You have to await the result, if you want
  to use it.

loadConfigRecordById

Parameters

configName - the name of the app

id - recordId to load

Result

The result is a brixxbox record object. All fieldvalues of that record are stored in data as key value pairs. (e.g. myRecord.data.addressName). The id of the record can be found in myRecord.id.

Example Usages

Simple (pay attention to the **[await](/globalDoc/glossary_await)** keyword)

javascript
   let myAddress= await brixxApi.loadConfigRecordById("address", 15);
   let addressName = myAddress.data.name;
   let id = myAddress.is;


description: Replaces a text with the current values of the app.

replaceText

Parameters

text - the text with parameters

additionalReplacings - json object with key value pairs

Example Usages

This example uses the controls of the app to replace the values.

javascript
   let newText = brixxApi.replaceText("Hello @id");

This example uses the controls of the app to replace the values.

javascript
   let newText = brixxApi.replaceText("Hello @myCustomParam", {
    myCustomParam: "world"
   });


description: brixxApi function to set a value to a field

setFieldValue

Parameters

controlId => Id of the control

value => The value, you want to set. This could be a number, a date, a string (depending on the control type of course). setFieldValue will do all the conversions for you.

Example Usages

1. Simple textbox

javascript
   brixxApi.setFieldValue("myControlId", "Hello World!");

2. With a variable

javascript
   let myText = "Hello World!";
   brixxApi.setFieldValue("myControlId", myText);

3. Setting a date

javascript
   brixxApi.setFieldValue("myDateControl", "2019-01-31"); //This is the format, you would get by getFieldValue
   brixxApi.setFieldValue("myDateControl", new Date()); //This will set todays date.
   brixxApi.setFieldValue("myDateControl", new moment().add(1, "month")); // you can use moment to set calculated dates. See https://momentjs.com/ for more details and examples

4. Setting a date to a calendar control scrolls to that date.

javascript
   brixxApi.setFieldValue("myCalendarControl", "2019-01-31");

5. The Calendar supports subcontrols to set. You can add resource(s) to the calendar for example:

```javascript
   //resources will delete all and set a new array of resources
   brixxApi.setFieldValue("myCalendarControl.resources", [
   {
       id: 1,
       title: "Room A",
   },
   {
       id: 1,
       title: "Room B",
   }]);

//resource will add a single resource
   brixxApi.setFieldValue("myCalendarControl.resource", {
       id: 1,
       title: "Room A",
   });
```

Demo

{% embed url="https://youtu.be/MRnw31QAt0M" %}


description: Initializes the app, so that you can enter a new record

newRecord

Example Usages

Simple (pay attention to the await keyword)

javascript
   await brixxApi.newRecord();


description: >-
  As the name suggests, this functions is to get date. This function when used
  without any arguments returns a date in this format 'yyyy-mm-dd'.

getDate

It is very important to be cautious because different date formats can lead into worng results when in comparison.

Parameters

param - (optional). If empty it will return todays date. User is also allowed to provide a date or moment object of javascript.

Example Usages

Following examples shows all three usages of getDate function. Lets suppose we want to know the new order placement date which is today then we can use 1st or second example. We also suppose that our order delivery date is after one month then we can use the third example and use this date as a delivery date.

javascript
   brixxApi.getDate();
   brixxApi.getDate(new Date());
   brixxApi.getDate(new moment().add(1, "month"));


description: >-
  Displays a modal messagebox with buttons. The function will return when a
  button is clicked and return the value, if set, otherwise the title of the
  clicked button

messageBox

Parameters

messageBoxOptions - A JSON object with messageBox parameters

Example Usages

```javascript
  let msgBoxResult = await brixxApi.messageBox({
     title: "sampel title",
     text: "sampel text",
     buttons: [
        {
            title: "Yes",
            value: "1"
        },
        {
            title: "No",
            value: "0"
        },
        {
            title: "Cancel",
            value: "canceled"
        },
        {
            title: "Demo" // when Demo is clicked it will return "Demo" because the button does not provide a value option.
        }
  ]});

console.log(msgBoxResult); //This will be either "1", "0", "canceled" or "Demo"
  if(msgBoxResult==1){
     //enter code
  }
```


description: >-
  This function is used to disable or enable app messages, that are displayed
  automatically, like the "record Saved" message, after a successful save
  operation.

enableNotifications

Parameters

param - The type of message. The following messages types are supported

"save" - The save Message

Example Usages

```javascript
   brixxApi.enableNotifications("save", false); //Disable the save message

brixxApi.enableNotifications("save", true); //Enable the save message (This is the default)
```


description: Creates a new grid line for a data grid.

newGridEntry

Parameters

The first parameter is a grid control

Example Usages

Simple (pay attention to the **await** keyword)

javascript
   await brixxApi.newGridEntry("myGridControl");


description: >-
  Sets the value, that is used to compare to the actual control value. If both
  are not equal, the field will be marked as changed.

setControlUnmodifiedValue

1. Simple Example Usages

javascript
   brixxApi.setControlUnmodifiedValue("myControlId", "unmodified Value");
   brixxApi.setControlUnmodifiedValue("myControlId", 1); // sets the value to 1.

2. Simple Example Usages with variables

javascript
   let valueToCompare = "Hello Wolrd!";
   brixxApi.setControlUnmodifiedValue("myControlId", valueToCompare);


description: opens the attachment sidebar with the attachment for the current record.

showAttachments

Parameters

show - open(true = default) or closes(false) the attachment sidebar. You don't have to worry if it is opend or closed before, but show will also refresh an open attachment.

Example Usages

javascript
   brixxApi.showAttachments(); //open the sidebar

javascript
   brixxApi.showAttachments(true); //open the sidebar

javascript
   brixxApi.showAttachments(false); //closes the sidebar


description: Changes the tag control to edit mode and vice versa.

switchTagControl

Parameters

controlId - String with the control id.

editMode - Optional boolean to determine if the control should be in edit mode or not. If not stated, the control will switch to it's other mode.

Example Usages

javascript
   brixxApi.switchTagControl('fieldId');

javascript
   brixxApi.switchTagControl('fieldId', true);


description: Displays a message to the user.

showMessage

Parameters

messageOptions- This is a json object with the message parameters:

content - this is the message Text

title - (optional) id of the record to load in the new app

timeout - (optional) a timeout in milliseconds. The message will disappear after this timeout. No timeout by default.

"mode" - (optional) will start in a modal overlay window (default),
"big" - (default) a small box in the lowerright corner of the page
"small" - a small box in the upper right corner of the page

icon - (optional) a icon class string (default: "fa fa-bell swing animated")

sound - (optional) play a sound (true) or no (false = default)

type - (optional) PReset color scheme. You can use all the button types (danger, success, warning...)

buttons - (optional, only for mode "big") You can add buttons to the message. Just provide a list with each button in square brackets (e.g. "[Yes][No][Cancel]"). For more details please check the examples.

callback - (optional, only for mode "big") If u provide more than one button the callback option is needed to distinguish which action needs to be taken for a button. For more details please check the examples.

Example Usages

Most simple message

javascript
   brixxApi.showMessage({content: "Message Text" });

using additional options

javascript
   brixxApi.showMessage({
            title: "My Title",
            content: "My Text",
            type: "danger",
            sound: true,
            timeout: 2000,
            icon: "fa fa-bell swing animated"
           });

message with buttons

```javascript
   //If u provide more then one button the callback option is needed to distinguish wich action needs to be taken for a button.

function msgCallBack (reasonForCallBack){
      // possible values for reason:
      // "click" : the message was closed with the X-button
      // "timeout" : the timeout elapsed
      // "btn1", "btn2", ...  : each button gets an id number (starting from 1). e.g. if the second button was pressed -> "btn2"


brixxApi.showMessage({
            title: "My Title",
            content: "My Text",
            type: "info",
            sound: true,
            icon: "fa fa-bell swing animated",
            buttons: "[Yes][No][Cancel]",
            callback: msgCallBack,
           });
```

message with buttons, timeout and changing the layout of the message after it was created

```javascript
   function msgCallBack (reasonForCallBack){
      console.log("reasonForCallBack:" + reasonForCallBack);
   }

let msgId = brixxApi.showMessage({
            title: "My Title",
            content: "My Text",
            type: "info",
            sound: true,
            timeout: 20000,
            icon: "fa fa-bell swing animated",
            //when using the timeout option the running timer value can be shown on one button. This
            //will visualize the default action taken after the timeout elapsed. Just add "{timer}" to a button text.
            buttons: "[   Yes {timer}][   No]",
            callback: msgCallBack,
           });

```


description: >-
  This function is used to toggle the row detail button, that opens the child
  app, based on the row data.

showRowDetailButton

Parameters

Row - the row object. Usually this is: eventArgs.details.row

show - shows (true, default) or hides (false) the detil Button

Example Usages

This code belongs in an onRowCreated event

javascript
   app.showRowDetailButton(eventArgs.details.row, eventArgs.details.data.icordlnIsBillOfMaterial===true);


description: >-
  Sets the auto refresh interval for grids. Only valid for grids with this
  setting enabled.

setGridAutoRefresh

Parameters

controlId - id of the grid control

autoRefreshSeconds - The value can be 0 to switch auto refresh off. Any other value must align with the defined values for this grid. For settings see Setting grid autorefresh

Example Usages

javascript
   brixxApi.setGridAutoRefresh(myGrid, 0); //this will switch the auto refresh off
   brixxApi.setGridAutoRefresh(myGrid, 120); //this will switch the auto refresh to 120 seconds (2 minutes). The parameter is only valid, if 120 is allowed with the settings for this grid.


updateTitle

Updates the title of the browser tab. You have to set brixxApi.appTitle property first and then update the title.

Example Usages

javascript
brixxApi.appTitle = "Hello World";
brixxApi.updateTilte();


description: Sets the text color for a control to one of the predefined colors

setTextColor

Parameters

controlId - the id of the control to change the color

colorName - one of these colors: "default", "primary", "secondary", "success", "danger", "warning"

Example Usages

Set Color to "warning"

javascript
   brixxApi.setTextColor("myControl", "warning");

Set Color to default

javascript
   brixxApi.setTextColor("myControl");


showMessageBox (deprecated)

brixxApi.showMessageBox

Displays a modal messagebox with buttons. Each button gets a function that is called when the button is clicked. The Messagebox will NOT block the script. The next line after the messagebox will be executed while the messagebox is still visible. If you want to wait for the button click. use waitForMsgBox instead.

Parameters

messageBoxOptions - A JSON object with messageBox parameters

Example Usages

javascript
   brixxApi.showMessageBox({
      title: "sampel title",
      text: "sampel text",
      buttons: [
         {
             title: "myButton",
             click: function(){
                 console.log("myButton clicked!!!!");
             }
         }
   ]});


description: Opens the discussion sidebar with the chat/discussion for the current record.

showDiscussion

Parameters

show - open(true = default) or closes(false) the discussion sidebar. You don't have to worry if it is opend or closed before, but show will also refresh an open discussion.

Example Usages

javascript
   brixxApi.showDiscussion(); //open the sidebar

javascript
   brixxApi.showDiscussion(true); //open the sidebar

javascript
   brixxApi.showDiscussion(false); //closes the sidebar


description: Shows a blob document in a docViewer control.

showBlob

Parameters

controlId - The id of a "docViewer" control

blobData - The blob data.

Example Usages

javascript
   let myBlob = brixxApi.getAttachmentByFileName("Invoice1.pdf");
   brixxApi.showBlob("myDocViewer", myBlob);


description: Deselects all rows with a specific value in a column.

unselectGridRows

Parameters

controlId - control id of the grid

columnId - id of the column to compare the value with

value - if the row has this value in the column with "columnId", it will be unselected

Example Usages

javascript
   brixxApi.unselectGridRows("myGrid", "id", 123);


description: Uploads an attachement

uploadAttachment

Parameters

data - The data as blob

documentTypeId (optional) - The ID of the document type to be saved

fileName - (optional) name of the attachement

Example Usages

javascript
   brixxApi.uploadAttachement(blobData, 1, "attachement.jpg");


description: Sets the grouping options for a grid control.

setGridGrouping

Parameters

controlId - the Id of the grid control

groupConfiguration - either null, or undefined to disable grouping, or a column (controlId)

Example Usages

javascript
   brixxApi.setGridGrouping(myGridControl); //Disables grouping
   brixxApi.setGridGrouping(myGridControl, productId); //groups by productId


description: Sets the font weight of a control.

setFontWeight

Parameters

ControlId

FontWeight - one of those: "normal", "bold"

Example Usages

Set to bold

javascript
   brixxApi.setFontWeight("myControl", "bold");

Set to normal

javascript
   brixxApi.setFontWeight("myControl", "normal");
   brixxApi.setFontWeight("myControl"); //you can skip param2 if you want to set it back to normal


description: >-
  A toolbar is a set of tools. These tools are assigned to each app present in a
  workspace in Brixxbox. A general toolbar for an app looks like this.

setToolbarButtonMode

Starting from left to right. The first button shows the list of records of current app. Second one (plus sign) open a new window of current app to add a new record. Third one is a save button, after adding all details in the app, user needs to click save button to permanently store the record. If the user presses "plus" button after adding required details, the record is not save but a new window will be opened so user should always press save button. Fourth button is a delete buton, as clear from name, it is used for deleting already present records. Next button is "History record" button, it records all the history of records being added.

The sixth button is "File Attachments" button. It is not present in the toolbar by default, system user has to enable it by going into app properties, scrolling down and clicking on "Attachments" checkbox. Next button is "settings" button, on clicking Brixxbox will open current app in edit or development mode with controls on left side and live app panel on right side. Next button shows the documentation available related to current app. Second last button is for openeing current app in a stand alone mode, it is a mode where only this app covers whole screen. Last button (x) is for closing the app. There are relative symbols present on each button so it is easier for user to be able to understand what each button does.

BrixxApi in its setToolbarButtonMode function provides the functionality to enable, disable or hidden. This is helpful in restricting access, functionality to different users, for example end user should not be allowed to delete any record so delete tool bar button should be hidden from these users.

Example

javascript
   brixxApi.setToolbarButtonMode("brixxToolbarNewRecord", "hidden");

Parameters

toolbarButtonId - This is first parameter. It is build in button ids assigned by Brixxbox to each toolbar button. These id are as follows:

brixxToolbarList - For listing records button.

brixxToolbarNewRecord - For adding records button.

brixxToolbarSaveRecord - For saving records button.


brixxToolbarNewRecord - For adding records button.

brixxToolbarSaveRecord - For saving records button.

brixxToolbarDeleteRecord - For deleting records button.

brixxToolbarHistory - For checking records history button.

brixxToolbarDiscussion - For discussion button.

brixxToolbarAttachments - For adding attachments button.

brixxToolbarEditConfigNewTab - For opening app in edit panel button.

brixxToolbarShowAppWiki - For show wiki documents button.

brixxToolbarOpenFullSize - For opening app in full size button.

mode - This is second parameter. It sets the state of respective button. These states are as follows:

"disabled" (or false or not clickable)

"enabled" (or true or clickable)

"hidden"

Example Usages

System user needs to pass button id and mode as a string parameters to this function. Lets suppose system user wants to hide a delete button from end users, there are many ways to do it. Let do it on an event when this app starts. Now we need to go to app properties and add event "onAppStart". Here we will place our code to hide delete button.

javascript
  brixxApi.setToolbarButtonMode("brixxToolbarDeleteRecord", "hidden");

After this save the app and try it. Now to toolbar should look like this:

Lets now hide all the buttons available in the toolbar on app start. For this we need to add below code to an event "onAppStart" custom code.

```javascript


```javascript

brixxApi.setToolbarButtonMode("brixxToolbarList", "hidden");
   brixxApi.setToolbarButtonMode("brixxToolbarNewRecord", "hidden");
   brixxApi.setToolbarButtonMode("brixxToolbarSaveRecord", "hidden");
   brixxApi.setToolbarButtonMode("brixxToolbarDeleteRecord", "hidden");
   brixxApi.setToolbarButtonMode("brixxToolbarHistory", "hidden");
   brixxApi.setToolbarButtonMode("brixxToolbarDiscussion", "hidden");
   brixxApi.setToolbarButtonMode("brixxToolbarAttachments", "hidden");
   brixxApi.setToolbarButtonMode("brixxToolbarEditConfig", "hidden");
   brixxApi.setToolbarButtonMode("brixxToolbarEditConfigNewTab", "hidden");
   brixxApi.setToolbarButtonMode("brixxToolbarShowAppWiki", "hidden");
   brixxApi.setToolbarButtonMode("brixxToolbarOpenFullSize", "hidden");
```

As you can see all the toolbar buttons are hidden except the "info" button. This is the default functionality.


description: Selects a Tab Page.

showTabPage

Parameters

controlId - id of the tabPage that should shown

Example Usages

javascript
   brixxApi.showTabPage("detalsTab");


description: Sets the label text for a control at runtime.

setLabelText

Parameters

controlId => Id of the control

labelText => the new text, you want to set

Example Usages

javascript
   brixxApi.setLabelText("myCheckBox", "Hello World");


takePicture

This triggers the camera to take a picture

javascript
brixxApi.takePicture("myCameraControl")


description: Toggles the grid selection for a whole grid.

toggleGridSelection

Parameters

controlId - control id of the grid

Example Usages

javascript
   brixxApi.toggleGridSelection("myGrid");


description: Sets the visibility for a specific control.

setVisibility

Parameters

controlId - id of the brixxbox control as a string

visible - (optional, default = true) bool value if the control should be visible or not

subControl (optional) Some controls have sub Controls, that can be set visible or hidden. Important: setVisibility for subcontrols cannot be used in onAppStart, because some controls are not fully created at that time, use onAppInitialized instead. Here is a list of possible subControls:

grids - The grid toolbar has to be active to see buttons at all!
buttons - shows or hides the buttons of a grid
buttonNew - shows or hides the new buttons of a grid
buttonDelete - shows or hides the delete buttons of a grid
buttonCopy - shows or hides the copy buttons of a grid

Example Usages

1. To show a control

javascript
   brixxApi.setVisibility("myControlId");
   brixxApi.setVisibility("myControlId", "visible");
   brixxApi.setVisibility("myControlId", true);

2. To hide a control

javascript
   brixxApi.setVisibility("myFieldId", false);

3. Hide the grid new button

javascript
   brixxApi.setVisibility("myGrid", false, "buttonNew");


description: >-
  Reads data from a Standard Sql Statement. See SQL Statements for how to create
  statements.

sqlRead

Demo

{% embed url="https://youtu.be/vs3uR5BRPKU" %}

Parameters

statementName - The name of the statement

additionalParameters - all controls in the current config are set as paramters automatically. If you need to add additional parameters, you can use this json object to set them

queryOptions - (optional) a json object with options for the request

timeout - (optional) timeout for the SQL request. Default is 30 seconds

connectionKey - (optional) a key to a custom settings entry with the connection string to an external MSSQL database

Example Usages

Lets assume, we have a standard statement "select adrName from address where id=@id"

javascript
   let result = await brixxApi.sqlRead("readAddress"); //this will use the statement "readAddress". The @id parameter is set to the id of the current loaded record in the app where we use this function
   console.log(result[0].adrName);

javascript
   let result = await brixxApi.sqlRead("readAddress", {id: 1}); //this will use the statement "readAddress". The @id parameter is set to 1
   console.log(result[0].adrName);

javascript
   let result = await brixxApi.sqlRead("readAddress", {id: 1}, {timeout: 60}); // Wait for 60 seconds
   console.log(result[0].adrName);

javascript
   let result = await brixxApi.sqlRead("readAddress", null, {timeout: 60}); //use a timeout but without script parameters
   console.log(result[0].adrName);


description: Starts a brixxbox app.

startBrixxbox

Parameters

startOptions - This is a json object with the start parameters:

appName - name of the config as string

noInitialRefresh - the grids of the target apps are not refreshed on startup. Can be used if you send additionalValues for the selection and you want to avoid to fetch data, that will be imidiately replaced with the correct filtered data.

parentApp - the parent for the new api. If not set, this will be set to brixxApi from the caller, your current api.

id - (optional) id of the record to load in the new app

startMode - (optional)
"modal" will start in a modal overlay window (default),
"tab" will start the app in a new tab. You will not get a brixxboxApi object as a result in this case!
"page" will replace the content in the current browser tab
"invisible" will not show the app

appMode - (optional)
"form" will start the app as a Form (default),
"list" will start the app as a List of Records,

additionalValues (optional): json object of control values that should be set in the new app

parameters: (optional): json array of parameter flags (the flags you can choose in the menu endpoint editor) to set for the new app

container: (optional): a jQuery object to a div, where the new brixxbox will be embedded

Return value

If a brixxbox is started in "modal" mode, the function returns the brixApi object of the new app. You have to await the result (Example 3) to use it.

Example Usages

This will start the app "myapp" in a modal dialog.

```javascript
   brixxApi.startBrixxbox({appName: "myapp"}); //starts myapp as a form

brixxApi.startBrixxbox({appName: "myapp", appMode:"list"}); //starts myapp as a list
```

This will start the app "myapp" in a modal dialog, load the record with id 1 and set the values of the 2 controls "addressNo" and "orderNo" inside the new app


```javascript
   let startOptions = {
      appName: "myapp",
      id: 1,
      startMode: "modal",
      additionalValues: {
         addressNo: 123,
         orderNo: 456
      },
      parameters:["openOrders", "shippedORders"]

};
   brixxApi.startBrixxbox(startOptions);
```

This will start the app "myapp" in a modal dialog, and add an addEventListener for the save event.

javascript
   let modalBrixxApi = await brixxApi.startBrixxbox({appName: "myapp"});
   modalBrixxApi.addEventListener("onRecordSaved", function (modalApi, eventArgs) {
      alert("Record saved in " + modalApi.appName);
   });


description: >-
  Uses a standard update or insert statement. See SQL Statements for how to
  create statements.

sqlWrite

Demo

{% embed url="https://youtu.be/vs3uR5BRPKU" %}

Parameters

statementName - The name of the statement

additionalParameters - all controls in the current config are set as paramters automatically. If you need to add additional parameters, you can use this json object to set them

queryOptions - (optional) a json object with options for the request

timeout - (optional) timeout for the SQL Request. Default is 30 seconds

connectionKey - (optional) a key to a custom settings entry with the connection string to an external MSSQL database

Example Usages

Lets assume, we have a standard statement "update address set adrName = @newName"

```javascript
   let result = await brixxApi.sqlWrite("updateAddress"); //this will use the statement "updateAddress". The @newName parameter is set to the field Value of "newName" of the app where we use this function
   console.log("Rows changed: " + result);

let result = await brixxApi.sqlWrite("readAddress", {newName: "Hello World"}); //this will use the statement "updateAddress". The @newName parameter is set to "Hello World"
   console.log("Rows changed: " + result);
```

javascript
   let result = await brixxApi.sqlWrite("readAddress", {newName: "Hello World"}, {timeout: 45}); //this will wait for 45 seconds until you get a timeout
   console.log("Rows changed: " + result);


description: >-
  Triggers an events for a control, or the brixxbox app itself. Some events are
  on brixxbox App level (like e.g. onRecordSaved ). Other events are on control
  level (like e.g. onClick)

triggerEvent

Example Usages

javascript
   brixxApi.triggerEvent("click", "myButton"); //This triggers a button Click for the control "myButton"
   brixxApi.triggerEvent("recordSaved"); //This triggers the event, that would otherwise occur if a record was saved

You can use the whole event name with the "on" prefix as well

javascript
   brixxApi.triggerEvent("onClick", "myButton"); //This triggers a button Click for the control "myButton"
   brixxApi.triggerEvent("onRecordSaved"); //This triggers the event, that would otherwise occur if a record was saved


description: Checks the field Validation for all controls.

validateInput

Example Usages

javascript
   brixxApi.validateInput();


description: >-
  Reads a single value from a standard sql statement. See SQL Statements for how
  to create statements.

sqlReadValue

Demo

{% embed url="https://youtu.be/vs3uR5BRPKU" %}

Parameters

statementName - The name of the standard statement

additionalParameters - (optional) all controls in the current config are set as paramters automatically. If you need to add additional parameters, you can use this json object to set them

columnName - (optional) the column name to pick from the first result line. If this is empty, the first column will be used

queryOptions - (optional) a json object with options for the request

timeout - (optional) timeout for the SQL Request. Default is 30 seconds

connectionKey - (optional) a key to a custom settings entry with the connection string to an external MSSQL database

Example Usages

Lets assume, we have a standard statement "select adrName, adrStreet from address where id=@id"

javascript
   let result = await brixxApi.sqlReadValue("readAddress"); //this will use the statement "readAddress". The @id parameter is set to the id of the current loaded record in the app where we use this function. The first column is adrName, so the value of adrName will be returned;
   console.log(result);

javascript
   let result = await brixxApi.sqlRead("readAddress", {id: 1}); // as above, but we overwrite the id from the app with a specific one
   console.log(result);

javascript
   let result = await brixxApi.sqlRead("readAddress", {id: 1}, "adrStreet"); // as above, but we overwrite the id from the app with a specific one and take "adrStreet" instead of the first column "adrName"
   console.log(result);

javascript
   let result = await brixxApi.sqlRead("readAddress", {id: 1}, "adrStreet", {timeout: 45}); // as above, but with 45 seconds timeout
   console.log(result);


setGridDefaults

brixxApi.SetGridDefaults

Sets the grid to its default values. Any setting for this grid for the user will be lost.

Parameters

controlId - id of the grid control

Example Usages

javascript
   brixxApi.SetGridDefaults(myGrid);


startScanner

Brixxapi allows users to scan barcodes or QR codes with startScanner function. It takes two parameters: control id, it is used to identify on which control the code value will be assigned, and options object in which we pass the bool value for continuous mode. Continuous mode, if true, provides the ability to keep the scanner open after reading code otherwise it will close. The process of reading codes consists of two steps. First step is to use this function. This function needs to be placed under a "Scanner" or "Wedge scanner" controls. When an event is triggered, this function will be called and it will access the camera of the device(if available). Now when it will read a code, this value will be assigned to scanner control in an app. In the second step, we can use this value by using getFieldValue function . It will be used to identify the object depending upon the code and a valueU Starts scanning QR or barcodes with the given scannerControl.

javascript
   app.startScanner("myScannerControl");

Parameters

controlId(String) - The control id of the scanner control (Check scanner control properties in an app).

scanOptions(JSON Object) - This is a json object with the scanner parameters(Used to specify the scanner functionality):

continuousMode(Bool - Optional - Default: false) - If true, it will keep the scanner open, after reading a code.

Example Usages

Start scanner with JSON options

javascript
   app.startScanner("myScannerControl", {
      continuousMode: true
   });

Here we are scanning a simpled bar code with a value of '12345678'.

After scanning the code successfully, the value will be assigned to the scanner control present in current app. Now there are many ways to use this value e.g conditionals (if statements). For this tutorial, we will just show the scanned value as a notification by using the code snippet given below. As soon as the scanner scans the code it triggers an "onScan" event. In this event, we can add our customized code.

Code when onScan Event get triggered

javascript
   app.showMessage({
       content: app.getFieldValue("myScannerControl")
   });

As we can see, it is showing the scanned value of '12345678'.


description: Sets the  tooltip text for a control at runtime.

setTooltipText

Parameters

controlId => Id of the control

text => the new text, you want to set

Example Usages

javascript
   brixxApi.setTooltipText("myCheckBox", "Hello World");


description: Displays a wiki page in the right sidebar.

showWikiPage

Parameters

pageName - The name of the wikie page (e.g. "function_showWikiPage")

global - Set this to true, if you want to display a page from the global wiki instead of a wiki page from your workspace wiki. The default is global=false.

Example Usages

Global documents

javascript
   brixxApi.showWikiPage("function_setVisibility", true);

Workspace documents

javascript
   brixxApi.showWikiPage("appConfigManual_address", false);
   brixxApi.showWikiPage("appConfigManual_address"); //2. parameter is false by default, so both lines give the same result


description: This function is used to toggle the row detail panel of a grid row.

showRowDetailPanel

Parameters

Row - the row object. Usually this is: eventArgs.details.row

show - shows (true, default) or hides (false) the detail Panel

Example Usages

This code belongs in an **onRowCreated** event

javascript
   app.showRowDetailPanel(eventArgs.details.row, eventArgs.details.data.icordlnIsBillOfMaterial===true);


description: >-
  Stores an inventory movement in a table with a certain structure. The Function
  handles database transactions and generates movement ids.

Inventory Movement

Mandatory fields: imItemId, imQuantity

Example Usages

javascript
   await brixxApi.businessBrixx({
        functionName:"InventoryMovement",
        movementTable:"inventoryMovement",
        movements:[
    {
                imQuantity: app.getFieldValue("quantityToShip") * -1,
                imAddressId: app.getFieldValue("companyId"),
                imItemId: app.getFieldValue("itemId"),
        imImei: app.getFieldValue("imei"),
        },
        {
                imQuantity: app.getFieldValue("quantityToShip"),
                imAddressId: app.getFieldValue("customerId"),
                imCustomerUserId: app.getFieldValue("customerUserId"),
                imItemId: app.getFieldValue("itemId"),
        imCustomerOrderLineId: app.getFieldValue("orderLineId"),
        imImei: app.getFieldValue("imei"),
        },
        ]
    });


description: Splits a GS1 code into its AIs and values

GS1 Code Splitter

This is usually used in the onScan event where you use the plain scan result as the input. The fnc1Char parameter is optional and only used, if the scanner sends an different (visible) character instead of the default fnc1 (CHAR29).

Mandatory fields: gs1Code

Example Usages

javascript
 let result = await brixxApi.businessBrixx({
     functionName:"Gs1Splitter",
     methodName: "Split",
     gs1Code: "011234567890123417210521109988"
 });
 console.log(result)

Example Usages with Split Char (FNC1)

Especially with keyboard wedge scanners, it is often usefull to use a visible character as the FNC1 char.

javascript
 let result = await brixxApi.businessBrixx({
     functionName:"Gs1Splitter",
     methodName: "Split",
     gs1Code: "011234567890123417210521109988X211234",
     fnc1Char: 'X'
 });
 console.log(result.applicationIdentifiers['10'])

The result variable in this case:

javascript
{
   "applicationIdentifiers":{
      "10":"9988",
      "17":"210521",
      "21":"1234",
      "01":"12345678901234",
      "01.packind":"1",
      "01.iln":"2345678",
      "17.date":"20210521"
   }
}


UPS Shiping

Contents

1 Business Brixx UPS Shipping

2 Business Brixx UPS Shipping -> CreateShipment

2.1 Incomming Information

2.2 Returning Information

2.3 Example Usages

3 CancelShipment

4 GetLabel

Business Brixx UPS Shipping

For accessing the UPS-Shipping brixxbox interface the UPS services need the following setup values (configuration -> settings).

UPSCustomerID Your customer number with UPS

UPSUsername A valid User for accessing the services

UPSPassword The corresponding password

UPSAccessLicenseNumber A license/access key provided by UPS on this page https://www.ups.com/upsdeveloperkit

If no settings are available, a sample label will be generated.

Business Brixx UPS Shipping -> CreateShipment

Creates a UPS shipping label

Incomming Information

To create labels four groups of information are available:

1. Settings with the following fields (If the group/field is not present default values will be assumed)

ServiceCode: default value "11" UPS Standard. Valid values according to UPS service codes.

MetricMeasurements: "1" sets to true. This is the default. Measurements will be metric e.g. kg, cm or nonmetric for lbs, inch

Language: Language code according to UPS. e.g. deu, eng, spa. this field will be set to user language by default. If the user language is not available for UPS, "eng" will be used.

2. Shipper:

Name

Street

HouseNo

ZipCode

City

CountryCode

StateProvinceCode

AttentionName

Phone

EMail

FaxNumber

TaxIdentificationNumber

3. ShipAddress:

Name

Street

HouseNo

ZipCode

City

CountryCode

StateProvinceCode

AttentionName

Phone

EMail

FaxNumber

TaxIdentificationNumber

4. ParcelData:

Description

PackageType: Package type according to UPS. If no value is given, the default will be set to: "02" Customer Supplied Package

Weight

Height

Length

Width

Returning Information

In case of success (status 200) the following fields are returned

TrackingNumber: The UPS generated ID. This will be used for further references to this shipment.


TrackingNumber: The UPS generated ID. This will be used for further references to this shipment.

LabelData: this is a blob response. It contains the actual label in GIF format and can directly be used for further processing. E.g. brixxApi.printBlob(LabelData);

In case of error (status 400) the following fields are returned:

error: a text showing the first error. E.g. console.log(result.error);

Example Usages

```javascript
var result = await brixxApi.businessBrixx({
      functionName:"UPSShipping",
      methodName: "CreateShipment",
            Settings : {
                Language: 'deu',
                MetricMeasurements: 1,
                ServiceCode: "11"
              },
            Shipper : {
                Name: 'Brixxbox GmbH',
                Street: 'HusarenstraÃe',
                HouseNo: '34a',
                ZipCode: '41836',
                City: 'HÃ¼ckelhoven',
                CountryCode: 'DE'
              },
            ShipAddress : {
                Name: 'Brixxbox GmbH',
                Street: 'HusarenstraÃe',
                HouseNo: '34b',
                ZipCode: '41836',
                City: 'HÃ¼ckelhoven',
                CountryCode: 'DE',
                Phone: '+49 1234 5678-9',
                Mail: 'm.mustermann@mustermann.com'
              },
            ParcelData : {
                Description: 'Product name',
                Height : 10,
                Length : 20,
                Width  : 15,
                Weight: '4.5',
                ServiceCode: '9'
              }
      });

console.log("Tracking Number: " + result.TrackingNumber);
brixxApi.printBlob(result.LabelData);
```

CancelShipment

To cancel an existing shipment only the TrackingNumber is needed.

javascript
var result = await brixxApi.businessBrixx({
      functionName:"UPSShipping",
      methodName: "CancelShipment",
     TrackingNumber: app.getFieldValue("ExistingTrackingNumber")
      });

GetLabel

In case the label is needed again it can be retrieved with an existing TrackingNumber. The result will show LabelData (see CreateShipment results #Returning_Information for details)


javascript
var result = await brixxApi.businessBrixx({
      functionName:"UPSShipping",
      methodName: "GetLabel",
     TrackingNumber: app.getFieldValue("ExistingTrackingNumber")
      });