search cancel

Add a column in OneClick to display attribute A or B if A is null or empty

book

Article ID: 256232

calendar_today

Updated On:

Products

DX NetOps

Issue/Introduction

How to add a column to a OneClick table, that display a model attribute, but if that attribute is empty or it doesn't exist, then display a different one.

The idea is to list in a table different models whose attribute ID that contains the value that needs to be displayed is not always the same.

Environment

Release : 21.2

Cause

Resolution

On the next example, the column "HA-State" will display the attribute 0xfff03605, but if that attribute is empty or null (doesn't exist for the model), then 0x6520013 will be displayed instead.

<column id="column-HaState-config.xml"
        xmlns ="http://www.aprisma.com"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.aprisma.com
                            ../../common/schema/column-config.xsd">

  <name>HA-State</name>

<content>
    <attribute>0xfff03605</attribute>
    <expression>
        (value() == null || ((String)value()).length() == 0) ?
        attr( 0x6520013 ) : value()
    </expression

</column>

Attachments