Skip to main content

Founding / Amendment Mode

Creating and Modifying a Record in the REST API

Written by Lenka Haringerová

When importing a record, you can define behavior based on whether the record already exists. This allows you to ensure that a related record is only imported if it does not yet exist. If it already exists, it is possible that a user has modified it, and therefore you may not want to import it again and overwrite its values.

The mode can be set individually for each record and also for each operation (create/update).

<?xml version="1.0"?>
<winstrom version="1.0">
<faktura-vydana update="ignore">
<id>123</id>
...
</faktura-vydana>
</winstrom>

Operation

Mode

Description

Create
(create)

ignore

If the record does not exist, ignore the request to create it.

fail

If the record does not exist, fail.

ok

If the record does not exist, create it normally. Default value.

Update
(update)

ignore

If the record already exists, ignore the request to update it.

fail

If the record already exists, fail.

ok

If the record already exists, update it normally. Default value.

A mechanism similar to row skipping can also be used for relations. Example:

<?xml version="1.0"?>
<winstrom version="1.0">
<faktura-vydana>
<firma if-not-found="null">code:FIRMA</firma>
...
</faktura-vydana>
</winstrom>

In this case, if a company with the code FIRMA is not found, the relation will be set to null instead (i.e., empty).

Operation

Description

null

If the record does not exist, do not set the relation.

nearest-invalid

If the record referenced by the code does not currently exist but existed in the past, the relation is set to the most recently invalidated record. The date considered is the document date, event date, etc. This is useful, for example, when importing historical documents with references to account numbers that are no longer valid.

create

If the record referenced by the code does not exist, it will be created automatically. For records of enumeration type, the code / name properties are populated based on the reference value (e.g., FIRMA / FIRMA - Vyplněno při importu). This method cannot be used to create records that have additional required properties.

Did this answer your question?