Skip to Content

Application programming model and criticality calculation

Hi,

I'm new to the Application Programming Model and CDS and I'd like to use the criticality annotation to display semantic colors in a list report. How should I compute the criticality, should I use a computed property or a view?

I just want to use a different color depending on the value of a property (percentChange24h):

if percentChange24h > 0 then use green (positive)

if percentChange24h < 0 then use red (negative)

if percentChange24h = 0 then use grey (neutral)

Cheers,

Pierre

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Nov 29, 2018 at 06:09 PM

    Hi Pierre,

    You can use a computed property on your CDS view. Just mare sure that the values are 1 (Negative), 2 (Critical), 3 (Positive). Then you can reference that property in your annotations as shown in this link.

    Cheers,

    Diego

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Diego,

      Could you tell me how to use a computed property, I've no idea how to do it.

      I found another solution by defining a view in my data model CDS but I don't know if this is the right way to do it:

      entity CurrenciesView as SELECT from Currencies {
      	*,
      	case 
      		when Currencies.percentChange24h < 0 then 1
      		when Currencies.percentChange24h > 0 then 3
      	end as change24hCriticality: Integer,
      };

      An then in my service CDS:

      entity Currencies as projection on cointracker.CurrenciesView;
      ...
      {$Type: 'UI.DataField', Value: percentChange24h, Criticality: change24hCriticality, CriticalityRepresentation: #WithoutIcon, "@UI.Importance": #High}
      ...

      Cheers,

      Pierre