This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Text colour to display alerts using custom query

Hi,

   I would like to display alerts using custom query and change text colour based on severity can you please advise how this can be achieved.

  • The custom query resource does not provide a way to control text color.

    The custom query custom table (reporting) resource allows unquoted HTML. You can use this to set the text color, perhaps by using a CASE ... WHEN ... END to choose the color based on some condition.

    Edit 2017-05-26: I mixed up which resource type allows HTML tags.

  • There are ways of incorporating color into custom queries but they are difficult.  The example below is generated by the custom sql that follows afterwards

    pastedImage_0.png

    select top 25

        EventTime,

        NetObjectID,

        Events.EventType,

        '<img src=/NetPerfMon/images/Event-' + LTRIM(STR(Events.EventType,10))  + '.gif> ' + '<a href=/Orion/View.aspx?View=NodeDetails&NetObject=N:' + LTRIM(STR(NetObjectID,10)) + '><font color=' + Icon + '>' + Message + '</font></a>' as Message

    from

        events join EventTypes on Events.EventType=EventTypes.EventType

    where

        NetObjectID in (select nodeid from nodes) and

        EventTypes.EventType in (1,2,5,8,9,14,40,41,100,940,941,942,3701)

    order by

        EventTime desc

    NOTE:  I removed a portion of the sql where clause to protect the guilty (me!)

    Chris

  • Good point! I forgot about that method.

  • Thanks for the clarification, can this be used in SWQL?

  • Like this:

    SELECT '<span style="color:' +

        CASE Status

            WHEN 0 THEN 'red'

            WHEN 1 THEN 'green'

            WHEN 9 THEN 'purple'

            ELSE 'black'

        END + '">' + Caption + '</span>' AS ColorCaption

    FROM Orion.Nodes

  • Agreed.  Your's is simpler.  I was recreating the exact color coding and icon selections in a special event view for a customer.

  • tdanner

    You say this works in the custom query, you sure thats not just in custom table/report?  When I try this code in a custom query resource I get this

    pastedImage_0.png

    I can use it successfully in a custom table by checking the allow HTML box.

    pastedImage_0.png

    Is there a bit I'm missing?

    And if that is WAI, how many cases of what liquor do I have to buy your devs to get an Allow HTML check box added to the custom query resource? (i'm only slightly joking)

  • No, you are not missing anything. I was mixed up on which resource had that option. I opened CORE-8624 to get the option added to Custom Query resource. Just write that bug number on the cases of liquor before you ship them. emoticons_happy.png

  • tdanner

    Is it possible to use CAST in SWQL?

    /MSARKAR

  • SWQL doesn't have a general-purpose CAST or CONVERT operation. There is a "ToString" function that will force any data to be a string. What kind of conversion do you need to do?