A.3 Agent_BuildDetailTableXML

This function builds an XML string describing a table, suitable for passing as the detail message to the Agent_CreateEvent and Agent_CreateData functions.

Required arguments:

  • $table_desc defines a hashtable that described the structure and content of the table, as shown below:

    @{ Title = <table title> Description = <table description> TableGUID = <table globally unique ID (GUID)> IsTransposed = <$true if column-based, else $false> DetailType = <either "Event" or "Data"> ColumnDefs = <array of hashtables defining columns> Rows = <array or hashtables holding table data> }

    Each entry in the ColumnDefs array should have the following format: @{ Name = <name identifying the column> Title = <the string used as the column title> ACType = <"ACName" or "ACValue"> }

    NOTE: The ACType is no longer used, but you still need to specify it. The need to specify this value will be removed in a future release of the product.

    Each entry in the Rows array should have the following format: @{ <column name> = @{ Text = <text to be displayed in this table cell> Style = <optional: CSS style to apply to the cell> } }

Returns:

  • This function returns an XML string suitable for passing to Agent_CreateEvent or Agent_CreateData as the detail message, resulting in the details being rendered as a table rather than as free-flowing text.

Example usage:

  • To define rows (first method):

    $rows = New-Object Collections.Hashtable[] 2 $rows[0] = New-Object Collections.Hashtable $rows[0]["Column1"] = New-Object Collections.Hashtable $rows[0]["Column1"]["Text"] = "Row 1 Column 1 Text" $rows[0]["Column1"]["Style"] = "font-weight: bold; color: black;" $rows[0]["Column2"] = New-Object Collections.Hashtable $rows[0]["Column2"]["Text"] = "Row 1 Column 2 Text" $rows[0]["Column2"]["Style"] = "font-weight: normal; color: black;" $rows[1] = New-Object Collections.Hashtable $rows[1]["Column1"] = New-Object Collections.Hashtable $rows[1]["Column1"]["Text"] = "Row 2 Column 1 Text" $rows[1]["Column1"]["Style"] = "font-weight: bold; color: red;" $rows[1]["Column2"] = New-Object Collections.Hashtable $rows[1]["Column2"]["Text"] = "Row 2 Column 2 Text" $rows[1]["Column2"]["Style"] = "font-weight: normal; color: red;"

  • To define rows (second method):

        $rows =
        @(
            @{
                Column1 =
                @{
                    Text  = "Row 1 Column 1 Text"
                    Style = "font-weight: bold; color: black;"
                }
                Column2 =
                @{
                    Text  = "Row 1 Column 2 Text"
                    Style = "font-weight: normal; color: black;"
                }
            }
            @{
                Column1 =
                @{
                    Text  = "Row 2 Column 1 Text"
                    Style = "font-weight: bold; color: red;"
                }
                Column2 =
                @{
                    Text  = "Row 2 Column 2 Text"
                    Style = "font-weight: normal; color: red;"
                }
            }
        )
    
    
  • To define columns (first method):

    $column_def_1 = New-Object Collections.Hashtable $column_def_1["Name"] = "Column1" $column_def_1["Title"] = "Column 1 Title" $column_def_1["ACType"] = "ACName" $column_def_2 = New-Object Collections.Hashtable $column_def_2["Name"] = "Column2" $column_def_2["Title"] = "Column 2 Title" $column_def_2["ACType"] = "ACName" $column_defs = @($column_def_1, $column_def_2)

  • To define columns (second method):

    $column_defs = @( @{ Name = "Column1" Title = "Column 1 Title" ACType = "ACName" } @{ Name = "Column2" Title = "Column 2 Title" ACType = "ACValue" } )

  • To define the table:

    $table_info = @{ Title = "My Table" Description = "My Table Description" TableGUID = "3cd66ae9-741a-447e-a8fc-7c67cedb066a" IsTransposed = $false DetailType = "Event" ColumnDefs = $column_defs Rows = $rows }

  • To build the XML string to be passed to the Agent_CreateEvent function:

    $table_xml = Agent_BuildDetailTableXML $table_info