Skip to Content
Jun 21 at 11:27 PM

Update i18n label using if-else condition in cds annotations

276 Views Last edit Jun 21 at 11:34 PM 4 rev

I am using filterBar as selectionFields and Table as LineItems in my below annotation.cds.

using service1 as service from './srv/xyz-service'

annotate service.XYZ with @(UI : {
selectionFields : [
LineItem : [
$Type : 'UI.DataField',
Value : Batch,
Label : {$edmJson: {
          $If: [{$Eq: [
              {$Path: 'OrderType'}, 'Discrete']},
                '{i18n>Label1}', // condition is true
                '{i18n>Label2}', // condition is false/else-block

We have a requirement to update the label dynamically like above. Hence, using edmJson, is it possible to update it?
The above code is not giving results as expected for else block, as the view does not refresh the new i18n label based on condition.