Skip to main content

User button

How to customize ABRA Flexi with custom buttons?

Written by Petr Pech

A custom button gives developers and users the ability to define a custom action in ABRA Flexi in the form of a button. When pressed, it displays a panel in the application or opens a web browser — in both cases with any web page.


Possible Uses

A custom button can be used to display a relevant part of an intranet information system, search for goods in a price comparison site, open the relevant part of the ABRA Flexi web interface, or trigger an action via the REST API. Parameters can be dynamically inserted into the web page address, for example the ID number of the company currently being edited, or the EAN of the displayed item.


Method of Use

The button's parameters — text, target URL, placement within the application — are written into its definition, an XML file. The created definition is loaded into ABRA Flexi via import from XML, and upon reconnecting to the company, the button becomes part of the user interface, whether in the client application or the web interface.

Buttons are stored in the custom-button record, so they can also be read normally via the API:

GET https://demo.flexibee.eu/c/demo/custom-button.json?detail=full


Custom Button Definition

Each element may appear at most once in the definition of a single button (with the exception of the id element). A file can contain multiple definitions; if the same button is listed multiple times, each definition is treated as an update, and the last one actually takes effect. An invalid definition will be rejected already during import.

Element

Required

Meaning

id

yes

Button identifier.

url

yes

Address that opens when the button is pressed.

title

yes

Text displayed on the button.

description

yes

Detailed description shown in the tooltip.

evidence

yes

The record type in which the button is displayed.

location

yes

Placement on the record list or on the record detail card.

browser

no

Browser in which the URL will open.

id

Record identifiers are used to assign a code when creating a button, and to precisely identify the button when later updating or deleting it. You can use:

  • Code (abbreviation) — a user-defined label, prefix code:

  • External identifier — an identifier from an external application, prefix ext:

  • ABRA Flexi identifier — a numeric, immutable identifier assigned by the application, without a prefix

When creating a button, this element must be specified with a code.

url

Specifies the address of the web page or network resource that opens when the button is pressed. Provide it in full, absolute form — including the scheme and the server's domain address, for example https://www.flexibee.eu/.

⚠️ Enter the URL in <![CDATA[ … ]]> so that the presence of the & character does not result in invalid XML.

🚨 The file scheme for accessing locally stored files is not supported — a definition with file:// will be rejected during import with the error restrictedProtocol.

When constructing the URL, you can include variables that are evaluated at runtime by FreeMarker, which ensures values are passed from the application. For example, the expression ${object.ic} returns the partner's ID number in the address book. The string object is mandatory in variable names — it refers to the current record of the displayed record type. A list of the available attributes for individual record types can be found in the web interface at addresses such as /flexi/{firma}/adresar/properties.

Variable

Value

object

The current record — its properties are specified after the dot, for example ${object.ic}.

objectIds

A comma-separated list of IDs of the selected records. For a large number of records, this is replaced by the data-url parameter — see below.

user

The currently logged-in user; for available properties see /flexi/{firma}/uzivatel/properties.

url

The full address of the object on which the button was triggered — for example https://demo.flexibee.eu/c/demo/adresar/1.

companyUrl

The address of the company's API interface — for example https://demo.flexibee.eu/c/demo/.

flexiUrl

The address of the company's web interface — for example https://demo.flexibee.eu/flexi/demo/.

evidence

The name of the record type on which the button is placed.

authSessionId

Authentication token for the current user session. It can be used to authenticate requests for the duration of the session's validity — see Authentication.

customerNo

The customer number corresponding to the license.

licenseId

The license identifier.

language

The language in which the application is running — cs, sk, en, de.

⚠️ The variables object and objectIds are mutually exclusive.

evidence

Specifies the record type, or optionally a specific relation of the record type, for which the button should be displayed — for example adresar for business partners or faktura-vydana for issued invoices. For the relation variant, for example faktura-vydana-polozka for issued invoice items, or majetek-zapujcka for loans in the asset record.

For record types, use the string that appears in the web interface URL. A list of all record types is returned by:

GET https://demo.flexibee.eu/c/demo/evidence-list.json

For record type relations, use the record type name followed by a hyphen and the relation string, which you can find on the relations overview of the given record type:

GET https://demo.flexibee.eu/c/demo/cenik/relations.json

A non-existent record type will be rejected during import with the error validace.neplatnyCiselnik.

location

Determines whether the button is displayed on the record list, or on the detail card of a specific record:

Value

Placement

list

Record list.

detail

Detail card of a specific record.

If the button should be available both on the record list and on the detail card of a specific record, you need to prepare two definitions that differ in the location value.

title

Text displayed on the button.

description

A detailed description of the button shown in the tooltip. It is required — without it, the import will fail with an error validace.notNull.

browser

Specifies the browser in which the URL will open. The internal browser opens faster, but may not include user customizations and data — passwords, cookies, form data, visited links. The external browser is the environment the user is used to.

Value

Browser

automatic

Internal browser; if unavailable, the external one opens instead. Default value.

desktop

External browser.

In the web interface, the browser setting is inherently ignored. An invalid value for either browser or location will be rejected with the error validace.notAvailableValue.


Creation Example

<?xml version="1.0"?>
<winstrom version="1.0">
<custom-button>
<id>code:JUSTICECZ</id>
<url><![CDATA[https://or.justice.cz/ias/ui/rejstrik-$firma?ico=${object.ic}&jenPlatne=VSECHNY]]></url>
<title>Obch. rejstřík</title>
<description>Zobraz záznam firmy v obchodním rejstříku justice.cz</description>
<evidence>adresar</evidence>
<location>detail</location>
<browser>desktop</browser>
</custom-button>
</winstrom>


Button Update Example

If you specify a unique identification of an existing button in the definition, you can update it. ABRA Flexi supports partial record updates, so when the business register address changes, it is enough to identify the button and provide the new URL value:

<?xml version="1.0"?>
<winstrom version="1.0">
<custom-button>
<id>code:JUSTICECZ</id>
<url><![CDATA[https://or.justice.cz/ias/ui/rejstrik-$firma?ico=${object.ic}&jenPlatne=VSECHNY&polozek=500]]></url>
</custom-button>
</winstrom>


Button Deletion Example

To delete an existing button, use the action attribute — for more on its use, see the article Performing Actions:

<?xml version="1.0"?>
<winstrom version="1.0">
<custom-button action="delete">
<id>code:JUSTICECZ</id>
</custom-button>
</winstrom>


Long URLs and the data-url Parameter

With a large number of selected records, a URL listing all the IDs could exceed the allowed length. In such a case, ABRA Flexi stores the list of IDs in temporary storage and, instead of the ${objectIds} variable, inserts the data-url parameter into the resulting URL, which points to an endpoint from which the full list of IDs can be downloaded.

For the http://example.com/action?ids=${objectIds} template, the resulting address might look like this:

http://example.com/action?ids=data-url&data-url=https%3A%2F%2Finstance.flexibee.eu%2Fc%2Fmojefirma%2Fcustom-button%2Fdata%3Fid%3D2f1c…

Downloading the List of IDs

The temporarily stored list of IDs is downloaded using the GET method at the address given by the data-url parameter:

GET https://demo.flexibee.eu/c/demo/custom-button/data?id=2f1c8b7e-1a2b-4c3d-9e0f-abcdef012345

The response has Content-Type: application/json;charset=utf-8:

{
"objectIds": [101, 102, 103, 104, 105]
}

The record is available only to the user who created it, and only for the duration of its validity. After expiration — or for a different user — the endpoint returns 404 with the code adresaNeplatna. An omitted id parameter results in the error 400 missing_param_exception.

Temporary Storage Configuration

The behavior of the temporary storage is governed by settings in the server configuration flexibee-server.xml (where to find it):

Option

Meaning

Default

objectStore.type

Storage type.

LOCAL (local file system)

objectStore.localDirectory

The directory on the server where data is stored when the type is LOCAL.

objectStore.defaultTtlMinutes

Validity period of the temporary record, in minutes.

60

objectStore.maxUrlLength

Maximum URL length, above which data-url is used.

2000


Related

Did this answer your question?