Skip to main content

REST API - Attributes

How to work with pricing and directory attributes in the REST API?

Written by Lenka Haringerová

Attributes let you store additional information about records — you can think of them as custom fields that extend the standard records. They are most commonly used with the price list for better comparison of goods; a detailed explanation of this agenda can be found in the guide Price List Attributes.

All attributes reside in a single record type, atribut. Which record an attribute belongs to is determined by the relation that is filled in:

Relation

Attribute belongs to

cenik

a price list item

adresar

a company in the address book

doklObch, doklFak, doklSklad, doklInt

a sales, invoicing, warehouse, or internal document

Only typAtributu is required — a reference to the attribute-type code list, which also determines the data type of the value (typAtributK): typAtribut.retezec, typAtribut.integer, typAtribut.numeric, typAtribut.datumCas, or typAtribut.boolean. The legend for individual fields of the code list is described in the article Attribute Code Lists.

ℹ️ Write the value into the hodnota element. Flexi will store it in the corresponding field based on the attribute type — valString, valInteger, valNumeric, valBoolean, or valDatCas — and when reading, you'll get both.

⚠️ Address book attributes can only be created, edited, and deleted via the REST API. However, they can already be displayed in the desktop application.


Price List

Price list attributes can be created, edited, and deleted both via the API and in the desktop application. You can retrieve them either as a subresource of the price list item, or directly from the attribute records:

GET https://demo.flexibee.eu/c/demo/cenik/42/atributy.xml
GET https://demo.flexibee.eu/c/demo/atribut/(cenik='code:CENIK').xml

⚠️ Filtering must be done by writing it in parentheses in the URL — this works on both endpoints, including /cenik/42/atributy/(hodnota='KUZE'). Conversely, the query parameter ?filter= is silently ignored on these endpoints, and all records are returned.

Importing an attribute:

<?xml version="1.0" encoding="UTF-8"?>
<winstrom version="1.0">
<atribut>
<hodnota>KUZE</hodnota>
<cenik>code:KUFR</cenik>
<typAtributu>code:MATERIAL</typAtributu>
</atribut>
</winstrom>

Editing an existing attribute — specifying the record's identifier:

<?xml version="1.0" encoding="UTF-8"?>
<winstrom version="1.0">
<atribut>
<id>1</id>
<hodnota>TEXTIL</hodnota>
<cenik>code:KUFR</cenik>
<typAtributu>code:MATERIAL</typAtributu>
</atribut>
</winstrom>

Removing an attribute using the action delete — just specify the identifier:

<?xml version="1.0" encoding="UTF-8"?>
<winstrom version="1.0">
<atribut action="delete">
<id>1</id>
</atribut>
</winstrom>

In the desktop application, the attribute then looks like this:


Address Book

The principle is the same, only instead of cenik, the adresar relation is filled in:

GET https://demo.flexibee.eu/c/demo/adresar/642/atributy.xml
GET https://demo.flexibee.eu/c/demo/atribut/(adresar='code:FIRMA').xml

Importing an attribute:

<?xml version="1.0" encoding="UTF-8"?>
<winstrom version="1.0">
<atribut>
<hodnota>DULEZITY</hodnota>
<adresar>code:FIRMA</adresar>
<typAtributu>code:VZTAH</typAtributu>
</atribut>
</winstrom>

Editing an attribute:

<?xml version="1.0" encoding="UTF-8"?>
<winstrom version="1.0">
<atribut>
<id>1</id>
<hodnota>NEDULEZITY</hodnota>
<adresar>code:FIRMA</adresar>
<typAtributu>code:VZTAH</typAtributu>
</atribut>
</winstrom>

And removing an attribute:

<?xml version="1.0" encoding="UTF-8"?>
<winstrom version="1.0">
<atribut action="delete">
<id>1</id>
</atribut>
</winstrom>

In the desktop application, the attribute then looks like this:


FAQ

Can price list items be filtered by attributes?

No, they cannot. A query such as /cenik/(atributy.hodnota='KUZE') returns 400 with the message Property 'atributy' does not exist. Filtering can only be done in the atribut records, and the resulting IDs can then be used to query the price list.

How do I work with price list attributes in the application?

Check out the guide for both the web and desktop interfaces.

Can attributes be imported from Excel?

Yes, but only for the price list — the procedure is described in Excel Import - Attributes.

How do I prevent duplicate attributes from being created during repeated imports?


Related

Did this answer your question?