In the piece of code below I can add entries almost automatically (the default provides the correct key value), but removing entries results in an error in the lower-right corner of the client: “The operation was lost before it was completed
”
'Verkoopregels': collection ['Verkoopregel']
'Volgorde regels': ordered-graph .'Is eerste regel' ( ?'Ja' || ?'Nee'>'Vorige regel' )
{
'Verkoopregel': text
@default: switch .'Is eerste regel' (
|'Ja' => "001"
|'Nee' as $ => to-text '' pad 3 with "0" sum ( $ >'Vorige regel'.'Verkoopregelnummer', 1 )
)
'Verkoopregelnummer': number '' = ( recurse 'Volgorde regels' ) switch .'Is eerste regel' (
|'Ja' => 1
|'Nee' as $ => sum ( $ >'Vorige regel'.'Verkoopregelnummer', 1 )
) @hidden
'Is eerste regel': stategroup (
'Ja' { }
'Nee' {
'Vorige regel': text -> ^ sibling in ( 'Volgorde regels' )
}
)
'Verwijderen': action { }
=> update ^ .'Verkoopregels' = delete //this entry
=> walk ^ .'Verkoopregels'* as $ ( //uses previously known entries...?
update $ .'Verkoopregel' = switch $ .'Is eerste regel' (
|'Ja' => "001"
|'Nee' as $ => to-text '' pad 3 with "0" sum ( $ >'Vorige regel'.'Verkoopregelnummer', 1 )
)
)
}
I guess the second action expression (=> walk ...
) somehow wants to use the entry that was present at the time before execution, which is deleted and therefore this expression can’t be executed.
A command uses the data store and therefore potentially the updated collection (if used correctly), but doesn’t allow the to-text
part and, after switching to command, removing the second expression and testing, only the last entry in the collection can be removed. Other entries in between can’t be removed.
Question: How to update the key value after removing entries from the collection?