Subsections of Template applications

Create

Basic info

To use applications for files, first we need to create an application entity.

Use the CREATE NEW -> Create new application from the menu to create one. Give the application a good clean name, it should follow the following rules:

  1. Not contain any special characters
  2. Start with a capital letter

You can link templates to the application from the application view screen, or you can link the template to the application in the template view under the ‘Publish settings’ right panel.

Note that templates in the application should have a unique name. Recommendation is to use some kind of prefix related to the application to describe the templates.

Example: My Test App -> mta-my-page

The linked templates list can be used to make the application create links to the application. There are 2 kinds of links

  1. Open menu link - this is the link that is created on the store application card, under the ‘Open’ button.
  2. Menu link - this is an actual link that is added to the Erply menu

Template list Template list

Green icon on the link button means a link has been defined.

Types

Currently, the application can be either a full, asset or module.

Read more about application types

Use the ‘Publish settings -> Module replacement’ configuration on templates to same what template its meant to replace as a module. Note that this setting is only used on module app’s and the replacement template type cannot be different from the current templates.

Add module replacement Add module replacement

Note

Asset and module type’s use a different kind of rating scheme and are not shown in the shop by default (visible with a filter).

Adding assets or modules to applications

Only full application can have assets and modules. In the application edit screen navigate to the asset or module connection area (under templates).

Note

Note that the asset or module needs to be published to the store first.

  1. Add assets/modules using the add button.
  2. Update connected versions by just re-adding them.

Create version and publish

In order to share the application to other accounts we need to publish to the store. Before the application can be published it needs to meet the following conditions:

  1. Have publishing permissions on the account for the application uuid
  2. Version needs to pass the application validation rules
    1. Have a rate higher than 0
      1. Valid application name, description and short description
      2. Not include partials or static files that are not used by the application
    2. Not include any critical validation errors
      1. Unlinked partials or static files
      2. Links to untrusted sources
    3. Not use file names that are already used by another application
    4. Has at-least one ‘Open’ menu link
    5. has at-least one Erply menu link

To publish the application the workflow would be the following: Validate version -> Create version -> Publish to the selected cluster

Application types

Applications have 3 different types

Full (default)

Standalone application, selected by default when creating a new application

Module

Extension to a specific full application. Files in the module can be set as replacements for files in the target full application.

Modules will be installed when the full app is installed automatically but the replacements will not be enabled until the user uses the configure modules functionality to enable it.

There is no limit to how many modules can be enabled at the same time, but only a single module can be active if multiple of them target the same file in the full application. Goerp will generate the module configuration groups based on this - modules that target unique files will be in a separate group and modules that target the same files will be in the same group.

Asset

Applications that can be shared between multiple applications.

Used to share styles, js functions or general purpose partials/pages.

Note that the version of the asset in the application indicates the minimum required version of the asset, installation will make sure that at-least this version is installed. It will not downgrade the version on the account if it has a higher version installed.

Asset package creator needs to make sure that updates to the app does not break used elements in previous versions, if this cannot be done then a new application should be created instead.

Logs

Application logs

The system collects application based errors into a short-lived memory that we can access for approximate 1 hour.

This can be used for debugging purposes or to check if the application is causing errors.

These logs are only captured for items that are connected to an application.

What is being recorded

  1. Failures in the editor for application connected templates
  2. Failures in page view’s for any possible api’s or the view generation logic itself
  3. Optionally the ‘debugDynApi=1’ can be added to the page parameters to record even successful requests. Note! If the template was recently linked to an application and the template was not save/updated then it might need a new re-save to properly start reading the debug logs.

This will make the application records all requests it makes even successful ones.

Where can the logs be seen

  1. Template edit view under the ‘Application logs’ right section. Right side menu Right side menu
  2. Under local application edit view. Content here is minimal as the api request data is not displayed.
  3. Under store application installation view. Content here is minimal as the api request data is not displayed.

Store errors indicator

The store will also indicate with a bug icon for the application if it has recently encountered errors.

Note that this will also capture template editing errors and can be used to reference encountered errors.

Moving applications

Moving application between accounts without using the store

Applications can be moved from one account to another without using the store interface. For this we can export the application and then import it to the other account using the export and import functionality.

Edit the application under ‘Developer mode’

Locate the application Locate the application

Move to the ‘Export’ tab

Open the ‘Export’ tab and click on the ‘Export’ button to download the application package

Open export tab Open export tab

Import the application

Open the account you wish to move the application to and open the ‘Developer mode’ view. Hover to the ‘Applications’ row to make the import button visible. On the new modal select the previously exported zip file and click ‘Import’.

Select the package Select the package

Wait for the process to complete. After this all the application should be available on the account.

Variables

Application static variables

Applications can use application accessible static variables that can then be used on all application connected templates.

Useful when a similar value is being used in multiple templates and for optimization where a static value is faster than trying to fetch one from an api.

These values can also be assigned into dynamic api requests parameters.

Create variables

In order to use the feature, first we need to create a ‘variables’ type file that is connected to the application.

Note

Application should only have a single variables file, if multiple are connected only the first one of them will be used.

Add vars file Add vars file

Contents

Contents of the variables file is in json format. The structure can have any kind of nesting or value types.

{
    "someKey": "someValue",
    "stuff": {
        "other": [
            {
                "id": 10
            },
            {
                "id": 12
            }
        ]
    },
    "defaultProductID": 21
}

Usage

The values can just be printed to the template or be used in dynamic api chaining features. The reading syntax is the same as reading dynamic api responses so all the same features and rules apply. More about dynamic response reading

Simple read

Reading values from the sample above

{{ .Variables.Get "someKey" }}
{{ .Variables.Get "stuff.other.#.id" }}

In dynamic api chaining

Reading value from the sample above

<input type="hidden" name="ErplyApi.Api.Post.myRequest1"
	data-preset-val="getProducts">
<input type="hidden" name="ErplyApi.Api.PostParam.myRequest1.<-productID"
    data-preset-val="Variables.defaultProductID">