# Low-code configuration

The configuration definition is available in the module **Application** Eximee Designer.

{% hint style="info" %}
Applications that use the configuration server to fetch configuration must have [Data model](https://docs.eximee.com/documentation/documentation-en/budowanie-aplikacji/model-danych) configured and a start point set.
{% endhint %}

When you go to a given application window in the left panel, the tab is available **Configuration,** and in the right window **the Configuration Editor**:

<figure><img src="https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2FVaNX5cnpjiN6710a4kIR%2Fimage.png?alt=media&#x26;token=cf881ce2-a592-4191-8649-05daecac7ae0" alt=""><figcaption><p><em><strong>Figure 1.</strong> Configuration from Eximee Designer - Configuration tab</em></p></figcaption></figure>

## Configuration format <a href="#konfiguracjazpoziomulowcode-formatkonfiguracji" id="konfiguracjazpoziomulowcode-formatkonfiguracji"></a>

Configurations are defined in the format: key = value

### Environment setup <a href="#konfiguracjazpoziomulowcode-ustaleniesrodowiska" id="konfiguracjazpoziomulowcode-ustaleniesrodowiska"></a>

Additionally, it is possible to specify the environment for which a given setting will be available by adding a suffix to the key **|${environment\_key}** e.g.

application.logi&#x6E;**|prod**=keyValue

Such a setting will by default be available only for the environment marked as "prod".

We can specify the environment using the ENV - **CONFIG\_SERVER\_ENVIRONMENT\_NAME** in the configuration server application.

If there is no key suffix with the current environment, values without a specified suffix are used.

### Comments <a href="#konfiguracjazpoziomulowcode-komentarze" id="konfiguracjazpoziomulowcode-komentarze"></a>

In the configuration editing window, it is possible to add comments to the configuration content. Comments should start on **a new line**, and the comment content should be preceded by the symbol **hash (#)**.

### **Definition of roles authorized to edit in Eximee Dashboard** <a href="#konfiguracjazpoziomulowcode-definicjaroluprawniajacychdoedycjiweximeedashboard" id="konfiguracjazpoziomulowcode-definicjaroluprawniajacychdoedycjiweximeedashboard"></a>

{% hint style="warning" %}
Please note that in addition to specifying roles in Eximee Designer that are authorized to edit a specific configuration in Eximee Dashboard, the Eximee Dashboard user must have an assigned role with the permission **feature\_config\_edit**, which gives access to the "Application Configuration" tab.
{% endhint %}

Along with the configuration in Eximee Designer, you can define roles that will enable editing the configuration [runtime](https://docs.eximee.com/documentation/documentation-en/zarzadzanie-aplikacja-biznesowa/zarzadzanie-konfiguracja/konfiguracja-aplikacji-biznesowej-serwer-konfiguracji/modyfikacja-runtime-konfiguracji-biznesowych) in Eximee Dashboard. If no roles are defined in the application configuration in Eximee Designer, editing the application configuration from Eximee Dashboard will not be available to any user.

Role definitions can be specified in the field "Roles authorized to edit in Eximee Dashboard" above the configuration editor in Eximee Designer.

If the configuration server application has the AUTH\_ROLE\_STRIP\_PREFIX parameter defined, then the given role prefix should be omitted in the list items.\
So if AUTH\_ROLE\_STRIP\_PREFIX = "PDC000000001-" and the role is called "PDC000000001-config-editor-role", then in the list in Eximee Designer you should indicate "config-editor-role".

\
Configuration modification in Eximee Dashboard: [Modification (runtime) of business configurations](https://docs.eximee.com/documentation/documentation-en/zarzadzanie-aplikacja-biznesowa/zarzadzanie-konfiguracja/konfiguracja-aplikacji-biznesowej-serwer-konfiguracji/modyfikacja-runtime-konfiguracji-biznesowych)

<figure><img src="https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2Fm7Ix0jsZyOEi6eJ0e1Q7%2Fimage.png?alt=media&#x26;token=ea671130-6f8b-49ca-86d1-128ad08a1bf8" alt=""><figcaption><p><em><strong>Figure 2.</strong> Configuration from Eximee Dashboard - "Application Configuration" tab</em></p></figcaption></figure>

### Configuration example <a href="#konfiguracjazpoziomulowcode-przykladkonfiguracji" id="konfiguracjazpoziomulowcode-przykladkonfiguracji"></a>

CONFIG\_SERVER\_ENVIRONMENT\_NAME = **dev**

Configuration content:

```editorconfig
#url links to test environment
test.url|dev=urlDev
test.url=urlDefault
 
test.password=passwordBasic
test.password|prod=passwordProd
test.password|dev=passwordDev
 
 
test.login|prod=loginProd
test.login=loginDefault
 
 
test.enabled=true
```

The config server for such settings will return 4 configurations (without suffix):

```editorconfig
test.url=urlDev
 
test.password=passwordDev
 
test.login=loginDefault
 
test.enabled=true
```

### **Configuration editing** <a href="#konfiguracjazpoziomulowcode-edycjakonfiguracji" id="konfiguracjazpoziomulowcode-edycjakonfiguracji"></a>

Configuration editing locks the application artifact, therefore no new artifacts can be added to it, e.g. a process, a form. However, attempting to add such an artifact **will create it in the repository**, but **it will not be attached** to the application artifact.<br>

In the case of syntax errors in the configuration (e.g. for a PROPERTIES-type configuration, invalid unicode was provided), an error will occur when saving the configuration, which will generally be in the form of errors occurring when saving the artifact:

<figure><img src="https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2FaHK7fwJ6iHMp5m3PxsJ8%2Fimage.png?alt=media&#x26;token=4a896e0a-1cb9-4338-a572-c50967e2f43f" alt=""><figcaption><p><em><strong>Figure 3.</strong> Error while saving invalid application configuration</em></p></figcaption></figure>

The user will remain in edit mode and will be able to correct any syntax errors and try saving the configuration again.

### Using values from configuration in ScriptCode <a href="#konfiguracjazpoziomulowcode-uzyciewartoscizkonfiguracjiwscriptcode" id="konfiguracjazpoziomulowcode-uzyciewartoscizkonfiguracjiwscriptcode"></a>

In ScriptCode we can retrieve a value from the configuration using the API for fetching configuration:\
\
API:

```typescript
interface Api {
    config: {
        v1: {
          get(key: string): string;
          getOrDefault(key: string, defaultValue: string): string;
        }
    }
}

```

example script using the Api:

```javascript
function callService(context) {
    let value1
    try {
        value1 = api.config.v1.get("dummy.url2");
    } catch(e) {
        value1 = "default"
    }
  
    var value2 = api.config.v1.get("dummy.url");
  
    var value3 = api.config.v1.getOrDefault("not_existing_key", "defaultValue")
  
    return [{'value1': value1, 'value2': value2, 'value3': value3}];
}

```

{% hint style="info" %}
\*Api also works for script calls in the data model.
{% endhint %}

The editor also offers suggestions:

<figure><img src="https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2FzftSGgEOhkY1lh4hjSTW%2Fimage.png?alt=media&#x26;token=4d348171-f8c9-4d38-8c30-21cdc4a0c482" alt=""><figcaption><p><em><strong>Figure 4.</strong> Example of a suggestion while typing code</em></p></figcaption></figure>

#### Using values from configuration in a script task <a href="#konfiguracjazpoziomulowcode-uzyciewartoscizkonfiguracjiwzadaniuskryptowym-przykladowezadanieskrytowe" id="konfiguracjazpoziomulowcode-uzyciewartoscizkonfiguracjiwzadaniuskryptowym-przykladowezadanieskrytowe"></a>

Example script task:

```javascript
function handle(task, context) {
    // Retrieving variables from the configuration
    const skipTask = api.config.v1.get("script.task.skip.task")
    const titleName = api.config.v1.getOrDefault("script.task.title.name", "Default title")
     
    // Completing the task and passing variables (skipTask, titleName) to the process
    context.complete({'skipTask': skipTask, 'titleName': titleName});
}
```

use in the process:

<figure><img src="https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2FSUcYUkvko5NETFnZ1Ab5%2Fimage.png?alt=media&#x26;token=59af233c-c457-4500-bb02-966c0a2951c7" alt=""><figcaption><p><em><strong>Figure 5.</strong> Example of using values from configuration in a process</em></p></figcaption></figure>

As a result, the values from the configuration will be passed to the process and saved under the keys: skipTask and titleName.

{% hint style="info" %}
Business configuration in Eximee: [Business Application Configuration](https://eximee.com/business-application-configuration/)
{% endhint %}
