Skip to main content

Tags

Working with Labels in the REST API

Written by Lenka Haringerová

Support for labels has been added throughout the ABRA Flexi system. Labels allow you to attach a status to various objects (e.g. documents, address book, orders, …) or to various states (e.g. payment method, etc.). This way, in a connected system, you can respond to situations where an invoice is paid using a method that has a label assigned (e.g. to trigger a method in an e-shop).

Note:

If you want to assign a label to a record, it must first be created in the label codebook.

Deleting / updating labels

Working with labels is slightly different because they are a relation emulated as an item. To delete or update labels, you need to use the removeAll="true" attribute:

<?xml version="1.0"?><winstrom version="1.0">  <adresar>    <id>14</id>    <stitky removeAll="true"/>  </adresar></winstrom>

The XML above will remove all labels from the specified record in the address book.

To update labels, simply provide the new list of values in the <stitky> element:

<stitky removeAll="true">STITEK1,NOVY_STITEK</stitky>


or in JSON:

"stitky@removeAll": "true", 
"stitky": "STITEK1,NOVY_STITEK"

Without specifying the removeAll="true" attribute, only non-existing labels will be added.

Exporting label groups

Labels can be organized into label groups. These allow for better processing during export (see below). If you configure a group so that a document can contain only one label, all other labels from the same group will be removed. This makes it easy to emulate a document status. An object will always contain only one label from a group that allows only a single label.

/c/{firma}/{evidence}.xml?skupina-stitku=SKUPINA1,SKUPINA2.

The output may look like this:

<winstrom>
...

<faktura-vydana>
...

<stitky SKUPINA1="STITEK1" SKUPINA2="STITEK2">STITEK1,STITEK2,STITEK3</stitky>
...

</faktura-vydana>
</winstrom>
Did this answer your question?