Skip to main content

Write a HTML table as an additional comment to a RITM

 

        var table_html = '<table style="width: 90%; margin: 20px auto; border-collapse: collapse;">';

        var rowIndex = 0;

        // Add table headers with styles

        table_html += '<thead><tr style="background-color: #0F52A2; color: white; font-weight: bold;">' +

            '<th style="padding: 10px; text-align: left;">Name</th>' +

            '<th style="padding: 10px; text-align: left;">Value</th>' +

            '</tr></thead>';

        for (var key in json) {

 

            if (json.hasOwnProperty(key)) {

                rowIndex++;

                var rowColor = (rowIndex % 2 === 0) ? '#f2f2f2' : '#ffffff'; // Alternate colors

 

                table_html += '<tr style="background-color: ' + rowColor + ';">' +

                    '<td style="padding: 8px; border: 1px solid #ddd;">' + key + '</td>' +

                    '<td style="padding: 8px; border: 1px solid #ddd;">' + json[key] + '</td>' +

                    '</tr>';

 

            }

        }

        table_html += '</table>';

        return table_html;

    },

 

    getInfoAttributes: function(json_payload) {

        /*

        Takes a JSON payload with key value pairs and strips out only those with 'info' in their name.

        */

        var json_payload2 = json_payload.replace(/\\"/g, '"'); //strip out the escape backslash

 

        var jsonPayload3 = json_payload2.replace(/\[(.*?)\]/g, function(match) {

            return match.replace(/"/g, "'"); //replace double quotes within square brackets (array) with single quotes

        });

        var result = {};

        var jsonPayload4 = JSON.parse(jsonPayload3);

 

        // Loop through all keys in the JSON object

        for (var key in jsonPayload4) {

            if (jsonPayload4.hasOwnProperty(key) && key.toLowerCase().includes("info")) {

                result[key] = jsonPayload4[key];

            }

        }

 

        return result;

 

    },

   

 

Flow action: