I have a data structure which can optionally hold a value if so I want to display it. In my example it is the field "quantity". However if it is set both blocks will be shown instead of just one. Where is the error?
{
"when": "${data.quantity === undefined}",
"type": "Text",
"text": "for ${data.price}",
"style": "textStyleDetails"
},
{
"when": "${data.quantity >= 0}",
"type": "Text",
"text": "${data.quantity}x for ${data.price}",
"style": "textStyleDetails"
},
I also tried the conditions:
data.quantity == 'undefined'
!data.quantity
(typeOf data.quantity) === 'undefined'
None of them work.
Try using ${data.quantity == null} Null is a recognized constant in the APL data binding syntax: https://developer.amazon.com/docs/alexa-presentation-language/apl-data-binding-syntax.html#null. Also the '===' operator is not supported in APL.