With an action
I’m updating 2 collections
. In one collection
I would like to add the key
of the just now created entry in the other collection
. The key
of this second collection
has an annotation @default: auto-increment
. How to know this key
while executing the action
?
Currently, I think there is no way to retrieve the key value when using the auto-increment
feature. The auto-increment
webclient feature was introduced as a temporary solution to provide support for human readable keys that should contain an ascending number (such as an invoice number in the Netherlands). In the future we plan to support it in a different (tbd) manner.
Can you provide more details on your specific use case? I may be able to suggest an alternative solution.
Another problem this question addresses is that a newly created entry cannot be accessed. Maybe by assigning it to a variable? Subsequent action steps should be allowed to access the newly created entry. But then there is the case of creating multiple entries. Maybe assign a collection of entries to a variable?
This is my (heavily stripped) model:
'Partijen': collection ['Partij']
'Bron': acyclic-graph
{
'Partij': text @validate: "[0-9]+" @default: auto-increment || "200000"
...
'Transacties': collection ['Transactie'] {
'Transactie': text @validate: "[0-9]+" @default: auto-increment || "001"
...
}
'Maak transactie': action { }
=> update ^ .'Partijen'
= create ( ... )
=> update .'Transacties'
= create ( ... ) // <-- here I would like to refer to the newly created Partij
}
The action
creates a Transactie
and a ‘destination’ sibling Partij
.
I was thinking about a reference-set
in Transacties
, but I don’t know if a reference-set
can handle an acyclic graph
, since it needs to figure out which sibling Partijen
refer to a specific Transactie
.
Thanks in advance.
The solution that you are suggesting yourself is a very good one I think. A reference-set
can hold sibling
references:
'Partijen': collection ['Partij']
'Bron': acyclic-graph
{
'Partij': text @validate: "[0-9]+" @default: auto-increment || "200000"
'Sources': collection ['Source'] {
'Source': text -> ^ sibling in ('Bron') -<'Usages'
}
'Usages': reference-set -> sibling .'Sources'* = inverse >'Source'
'Maak transactie': action { }
=> update ^ .'Partijen'
= create (
'Sources' = create (
'Source' = .'Partij'
)
)
}