Skip to main content

Previous Value – How to Respond to a Change

React to change feature

Written by Lenka Haringerová

The system includes the ability to react to changes, and you can use this from another system as well. This feature is typically used in combination with ?dry-run=true in cases where you provide data to the user for direct editing.

A user expects that if they change the company code on an invoice, the company name will be overwritten accordingly. However, the company name must also be present in the form so that the user can change it. The previous value can be used to define the reaction to this change. Multiple previous values can be used within a single request.


Example

A request specifying the previous value:

<?xml version="1.0"?>
<winstrom version="1.0">
<faktura-vydana id="123">
<firma previousValue="code:JINA FIRMA">code:FIRMA</firma>
<nazFirmy>Jiná firma</nazFirmy>
</faktura-vydana>
</winstrom>

The response then looks like this — the company name was overwritten based on the newly selected company:

<?xml version="1.0"?>
<winstrom version="1.0">
<faktura-vydana id="123">
<firma>code:FIRMA</firma>
<nazFirmy>Firma</nazFirmy>
</faktura-vydana>
</winstrom>

If the previous value were not specified, the response would look like this — the company name remains as it was sent:

<?xml version="1.0"?>
<winstrom version="1.0">
<faktura-vydana id="123">
<firma>code:FIRMA</firma>
<nazFirmy>Jiná firma</nazFirmy>
</faktura-vydana>
</winstrom>


Why use this

If you wanted to achieve the same effect without specifying the previous value, you would have to omit the attributes related to the changed attribute. This would require you to know all the dependencies that rely on the current data as well.

ℹ️ The change-reaction process is only triggered when an actual change has occurred. For example, if you change the document type but it doesn't change the posting rule, the debit and credit accounts will not be overwritten.


JSON notation

In JSON format, the value is specified as an additional tag named firma-previousValue:

{
"winstrom": {
"@version": "1.0",
"faktura-vydana": [{
"id": "123",
"firma": "code:FIRMA",
"firma-previousValue": "code:JINA FIRMA",
"nazFirmy": "Jiná firma"
}]
}
}


Related

Did this answer your question?