Skip to main content

API-based Document Locking

Lock, unlock, and lock-for-accounting actions — and why unlocking and editing cannot be combined

Written by Petr Pech

Individual documents can be locked against changes via the API — and unlocked in the same way. This is done using actions on the document record.


Actions

Action

What it does

lock

Locks the record.

lock-for-ucetni

Locks the record for the accountant.

unlock

Unlocks the record.

Writing is a regular import with the action attribute:

<winstrom version="1.0">
<faktura-vydana action="lock">
<id>123</id>
</faktura-vydana>
</winstrom>

The action can also be run in batch mode on a group of records defined by a filter:

<winstrom version="1.0">
<faktura-vydana action="lock"
filter="stavUhrK = 'stavUhr.uhrazeno' and typDokl = 'code:INTERNET'">
</faktura-vydana>
</winstrom>


Modifying a locked document

Attempting to modify a locked record will result in an error:

Záznam je zamčený.

🚨 Unlocking and editing cannot be combined into a single request. If you send action="unlock" together with changed properties, the server will respond with success=true, but the changes will be discarded — only the unlock will take effect. Split the operation into two separate requests instead: first unlock, then modify.


Document in a locked period

A document lock is different from a period lock. A document cannot be inserted into a locked period until you switch the lock to zamek.otevreno — the procedure is described in the article Locking Periods via REST API.


Related

Did this answer your question?