In the following code I’m not allowed to use the concatenation in this way. The error says: “unexpected keyword ‘concat’ while making a decision for stategroup ‘operation’ of !‘command expression’”. How would I be able to give a concatenation as an argument to a command in an application running version Uhura.2?
'Add Description': command {
'Description': text
} => update .'Descriptions' = create (
'Description' = concat ( ^ .'Part 1', " ", ^ .'Part 2' )
)
You currently have two options. You can pass a concatenation as an argument to the command invocation via a default expression, like this:
'Add Description': command {
'Description': text @default: concat ( ^ .'Part 1', " ", ^ .'Part 2' )
} => update .'Descriptions' = create (
'Description' = @ .'Description'
)
Alternatively, you can use an action
instead of a command
if Add Description
is meant for the end user of your application. An action
expression supports concatenation.
Can I ask why want to do this kind of concatenation? Would it be possible to solve the problem you face differently? In my experience, this kind of concatenation – for constructing a key value – often points to a code smell or a missing language feature.
I’m trying to deliver a description of an invoice line consisting of a Shoe model and variant. The command is send to another system through an interface. So I’m using this command with an execute.
Okay, so you have a collection of Order lines
and not of Descriptions
, which makes more sense to me. I suppose then that Description
is not the key of an Order line
, which the above example suggests? Either way, you can implement the command
like this:
'Description for invoice': text = concat ( .'Part 1', " ", .'Part 2' ) // derived text value
...
'Add Description': command { } => update .'Descriptions' = create (
'Description' = .'Description for invoice'
)