# Data Connection

Komment allows for three different methods to be used when saving data.&#x20;

### QIX Engine

> Utilizes the built-in QIX Engine API for processing the writing mechanism. Partial reload is performed by the Qlik Sense user.

{% hint style="warning" %}
Does not support Qlik Analyzer license&#x20;
{% endhint %}

### Kaptain

Kaptain is an added service that you can purchase to enhance the functionality of Komment. There are several reasons as to why Kaptain might be relevant for you:

{% hint style="success" %}
You have a need for **SQL DB storage** of saved data => Kaptain enables writeback to external databases. We currently support MS SQL, MySQL, PostgreSQL, Oracle DB & MongoDB.
{% endhint %}

{% hint style="success" %}
You have a high number of **concurrent users** using Komment => Kaptain can handle high concurrency cases (i.e. several users saving comments at the same time)
{% endhint %}

{% hint style="success" %}
You will use Komment in **larger** Qlik applications (+200 mb) => Kaptain **increase performance** to near **real time** save and hence, better handling of large Qlik applications.
{% endhint %}

{% hint style="success" %}
You require **dynamic** updates to Komment data model to be possible => Kaptain allows for dynamic updates to Komment data model **without breaking** with historic data structure - i.e. you can freely add new data entry fields to your existing Komment objects.
{% endhint %}

{% hint style="success" %}
You have **Analyzer** licenses => Kaptain enables Analyzer users to store data using Komment
{% endhint %}

{% hint style="success" %}
You want to be prepared for the **future** => Kaptain will soon make it possible to connect your Qlik Sense apps with many **external services** which expands the possible use cases for Komment
{% endhint %}

Just contact us if you would like to add Kaptain to your Qlik Sense writeback solution.

### Comparison

| Feature/Element                               | QIX engine | Kaptain |
| --------------------------------------------- | :--------: | ------- |
| Security rule setup needed                    |     Yes    | No      |
| Each user must have ‘CommentingRole’ assigned |     Yes    | No      |
| Concurrency handling                          |     No     | Yes     |
| Supporting Analyzer License users             |     No     | Yes     |
| Extra node.js service to be installed         |     No     | Yes     |
| Partial reload needed when saving data        |     Yes    | No      |

### Kaptain Configuration

The setup is made in the Data Connection Settings section. The default is QIX Engine so if you don't have a plan (Standard, Pro or Premium) where Kaptain Service is included you don't have to touch this section.

1. Select your Connection Type

2. Input the URL to Kaptain service

   1. If you have multiple environments (devl, test, prod, etc.) you can ease the setup by defining a variable that holds the URL
   2. Then you just reference this variable in the URL field:

   &#x20;<img src="https://3285996621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M3GVUHw4oTRoOiEo4EB%2F-MLD9mgavHhOg-EyDuPO%2F-MLDB0fSf1a14RrCq_W_%2FKaptain_URL.png?alt=media&#x26;token=0a827695-ecc0-47fd-accd-ea98833df173" alt="" data-size="original">&#x20;

3. Press `Test Service` to ensure Komment and Kaptain service are connected

![](https://3285996621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M3GVUHw4oTRoOiEo4EB%2F-MI375_sJXnGj-wAyV78%2F-MI387P1-gl4DCfvllJ0%2FData%20connection%20settings2.png?alt=media\&token=a343b80a-c287-4263-a1e7-913ad5855d4f)

{% hint style="info" %}
Be aware of the protocol, and service port, that needs to be consistent with the settings in Kaptain config file.
{% endhint %}

### Kaptain Settings

To setup your Komment object to work with Kaptain there are only a few steps needed. You find the Kaptain Settings Under Data Connection Settings:

![Kaptain settings](https://3285996621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M3GVUHw4oTRoOiEo4EB%2Fuploads%2FdfzfWfmDbFnuVXHmPyIw%2Fkaptain_settings.png?alt=media\&token=9eff0c8b-224c-44bb-bf7e-4b49143b618a)

#### 1. Select or Create Kapsule

Here you define where in Kaptain's internal database you want to save the data entered by the users when using Komment. A **Kapsule** corresponds to a collection in the database. You can think of it as a table in a SQL database.

* If you have already created a Kapsule you can select from the list

![](https://3285996621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M3GVUHw4oTRoOiEo4EB%2Fuploads%2FDfiFNe1Dy94n2QfNdmGF%2Fselect_kapsule.png?alt=media\&token=3a777d5a-035e-41f9-ae08-b344f35ae562)

* If not, then

  * &#x20;Press `Create New Kapsule`&#x20;
  * You will now be presented with the following window:

  <img src="https://3285996621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M3GVUHw4oTRoOiEo4EB%2Fuploads%2FI4dLbUQqS4IJGTOI7e4I%2Fcreate_kapsule.png?alt=media&#x26;token=8a397163-c77d-422b-bdbc-95eada4b51b5" alt="" data-size="original">

  * If you want to store data in Kaptain's internal DB do the following:
    * Enter a Name for your new Kapsule
    * Choose KaptainDB as your database
    * Press `OK`
  * If you want to store data in an external DB do this:

    * Enter a Name for your new Kapsule
    * Choose your desired DB from the list

    ![](https://3285996621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M3GVUHw4oTRoOiEo4EB%2Fuploads%2FXGHTzgXfvuGh0BONxdj5%2Fchoose_db.png?alt=media\&token=9f939af1-3c85-4202-91cd-2b012dc78a49)

    * If you want to use an existing table in the selected DB then choose your database table from the dropdown and press `OK`

    ![](https://3285996621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M3GVUHw4oTRoOiEo4EB%2Fuploads%2FbvhtWKwH0OVwsS7lJo5p%2Fchoose_db_table.png?alt=media\&token=6ecaaa3f-ad11-4a8f-a014-db820d890b89)

    * If you want to create a new table in your selected DB then press `Create SQL table`

      * Enter the name of the new table and press `OK`

      ![](https://3285996621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M3GVUHw4oTRoOiEo4EB%2Fuploads%2FK1Gfp3CRg0kyeBI7E9Wd%2Fcreate_db_table.png?alt=media\&token=25e64f6b-a922-418a-ba19-30b46d98889a)

      * A pop-up message will be displayed indicating that the table has been created
      * Select your newly created table from the dropdown

      ![](https://3285996621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M3GVUHw4oTRoOiEo4EB%2Fuploads%2Fa0DU3zsSVVFHj87zt1eG%2Fchoose_db_table2.png?alt=media\&token=393d9ff0-377b-4147-ac20-3e7d1a47a262)

      * Press `OK`
  * Press outside the Komment object on the sheet and afterwards press the Komment object again
  * &#x20;In the Kaptain Settings menu you can now select the newly created Kapsule in the list

  ![](https://3285996621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M3GVUHw4oTRoOiEo4EB%2Fuploads%2F00a0xvIqA1z2TMvQBTpc%2Fselect_kapsule2.png?alt=media\&token=e607016d-9a44-4a67-aaca-c213bc4616f7)

{% hint style="info" %}
If you cannot find specific Kapsules in the dropdown menu, contact your admin to ensure you are setup as a Kaptain user and is member of the groups that contain the relevant Kapsules.
{% endhint %}

{% hint style="info" %}
If you are not able to create a new Kapsule, contact your admin to ensure you are setup as a Kaptain user and has the permissions the create kapsules.
{% endhint %}

**2. Use variable to select Kapsule dynamically**

To be able to easily moved applications with Komment between different Qlik servers and Kaptain installations you can define the Kapsule dynamically using a variable. Here is how.

* After you have selected your Kapsule as described above, you do the following:

  * Copy the Kapsule ID shown below the Kapsule you have selected

  <img src="https://3285996621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M3GVUHw4oTRoOiEo4EB%2Fuploads%2FdfzfWfmDbFnuVXHmPyIw%2Fkaptain_settings.png?alt=media&#x26;token=9eff0c8b-224c-44bb-bf7e-4b49143b618a" alt="" data-size="original">&#x20;

  * Create a new variable using Qlik's variable editor (or define in script) and insert the copied value in the variable value
  * In Kaptain settings switch on `Dynamic Kapsule`
  * Input the the name of the newly created variable

  <img src="https://3285996621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M3GVUHw4oTRoOiEo4EB%2Fuploads%2FlWiP8wcl19cw2VBQUHx8%2Fdynamic_kapsule.png?alt=media&#x26;token=1ab5e6c2-4d9d-4ec7-bcfc-7bc5634718a7" alt="" data-size="original">&#x20;

#### 3. Kaptain Data Connection

Here you can create a Qlik Sense Data Connection that will ensure you can load data from Kaptain. You just choose a name and a REST connection to Kaptain will automatically be established.

![](https://3285996621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M3GVUHw4oTRoOiEo4EB%2F-MI4JEwYKMuWnVj6nFdm%2F-MI4O7lEKrkIEnak_Q4e%2FKaptain%20data%20connection.png?alt=media\&token=c6d17dbe-97b6-4b68-a66a-c6cc961270cb)

* If a REST data connection to Kaptain is already created you can select this
* If not, then
  * Press `Create Connection`
  * Write desired name of connection in pop-up window
  * Press `OK` (browser window will automatically refresh)
  * Select the newly created data connection from the list&#x20;

#### 4. Optional settings

<figure><img src="https://3285996621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M3GVUHw4oTRoOiEo4EB%2Fuploads%2FwlEp2nGz2tzlelWVCmcv%2FKaptain_options.png?alt=media&#x26;token=b2bf93cd-c2b5-4e38-9801-6e9d19dc97f0" alt=""><figcaption><p>Optional settings</p></figcaption></figure>

`Load Full History:`&#x20;

Defines how much of the history data you load from Kaptain and into your Qlik Sense app on each reload (partial and full). By default only the latest record for each Komment Key field will be loaded so to get the full audit trail loaded each time toggle on this option.

`Skip Reload:`&#x20;

When this option is enabled, Kaptain will not perform a partial reload after the user press save. This means that the stored data will only be visible in the Komment table and not any native Qlik objects. The reason is that the saved data will not be included in the Qlik data model until a full reload of the app is performed.&#x20;

When to use the Skip Reload function? If you have large applications where partial reloads takes a long time. Or if you do not need to make use of the saved data in any Qlik visualizations in real time.

`Reload Notification:` When this option is enabled the user will see information about the partial reload status after pressing save.

When to show the Reload Notification function? If you have large applications where partial reloads takes a long time and you want to give the user an indication of the reload process.

{% hint style="warning" %}
Remember to initialize the data model again after you have finalised the Kaptain setup
{% endhint %}

![](https://3285996621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M3GVUHw4oTRoOiEo4EB%2F-MBrLuBOfu8GhlTMmzVm%2F-MBrM6bsNs9QJqOMRu5H%2FPreviewLoad.png?alt=media\&token=6c1cb244-9c05-4fe5-b4c3-a80ee25c575e)

![Initialize Data Model](https://3285996621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M3GVUHw4oTRoOiEo4EB%2F-M3H3j8NLDQyDiwjyX_l%2F-M3H5FGX0iW7Zt91h_7j%2Fimage.png?alt=media\&token=ac5d5c95-79d2-4044-a924-7a81b1c32ba2)

#### 4. Sync Kapsule

if you  add new widgets or remove existing widgets in your Komment setup you need to press `Sync Kapsule` to enforce the changes to be reflected in the Kapsule.

<div align="center"><img src="https://3285996621-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M3GVUHw4oTRoOiEo4EB%2F-MSgVJaMLMug6Qjs0uqu%2F-MSgWHaGn3C_smCj73VZ%2FSync%20kapsule.png?alt=media&#x26;token=783472dc-0b7f-4b5f-ad5f-4995de449a41" alt="Sync Kapsule"></div>

**5. Known limitations**

`Field names:`

The field names used in the Komment widgets cannot contain the following characters: `. $`

`Kapsule names:`

Kapsule names should begin with an underscore or a letter character, and *cannot*:

* contain the `$`.
* be an empty string (e.g. `""`).
* contain the null character.
* begin with the `system.` prefix.

You can learn more here: <https://docs.mongodb.com/manual/reference/limits/>

###

### Date settings

When using Kaptain as a data connection you have a few more option in relation to the Date widget. The below settings will only affect how the dates entered in the date widget are stored in MongoDB and how they are represented in Komment.

![Date settings](https://3285996621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M3GVUHw4oTRoOiEo4EB%2Fuploads%2FP7MVfivMO8kLZNsEzK6o%2FKomment_date_settings.png?alt=media\&token=4d663e3d-f82c-4163-b355-2995761bc73f)

#### Custom Date Format:

By enabling Custom Date Format you get the possibility to set your own Date Format. Note that it is case sensitive.

#### Ignore Timezone:

If you have users in many different time zones you can also tick Ignore **Time zone** to ensure that the selected date will be displayed exactly the same to all users.&#x20;

{% hint style="info" %}
If you make the settings to an existing Komment object make sure to Sync Kapsule and do a full reload to make sure your changes have been applied.
{% endhint %}

#### Server Timezone:

Again, if you have users in different time zones then use this setting to define in which time zone the server on which Kaptain is installed resides in. This is to ensure that no date shift due to different time zones is happening when displaying dates from the date widget.

**Example use case:**

The server on which Kaptain is installed is in UTC -05:00 time zone.&#x20;

The users are in many time zones - e.g. Europe and US.

`Recommend date settings:`

Ignore Timezone => Active

Server Timezone => UTC -5:00

![](https://3285996621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M3GVUHw4oTRoOiEo4EB%2Fuploads%2FdCStzKSzUoJn0mvlpudZ%2Fimage.png?alt=media\&token=24f458d5-8f03-477f-b8c8-f223df839786)
