Hello,
Could someone provide an example of the table HTML for the predefined views?
I would like to use this template to display JSON results from a QRadar AQL query.
The current template uses static results. What modifications are needed to configure it to use dynamic JSON results and include fields such as Source IP, User-Agent, and Location?
Thank you!
Solved! Go to Solution.
<table>
<thead>
<tr>
<th>Source IP</th>
<th>User-Agent</th>
<th>Location</th>
<!-- Add more columns as needed -->
</tr>
</thead>
<tbody id="dynamic-data">
<!-- This section will be populated dynamically with JSON results -->
</tbody>
</table>
// Assume 'jsonData' is the JSON result from the QRadar AQL query
const tableBody = document.getElementById('dynamic-data');
jsonData.forEach((row) => {
const tableRow = document.createElement('tr');
tableRow.innerHTML = `
<td>${row.SourceIP}</td>
<td>${row.UserAgent}</td>
<td>${row.Location}</td>
<!-- Add more columns as needed -->
`;
tableBody.appendChild(tableRow);
});
Adding some more details on getting JSON data into the widget:
A simple 1d string, note how the placeholder will resolve a STRING so you need to encapsulate with ""
<script>
simpleString = "[ActionName.ScriptResult]"
</script>
To get a full JSON that you can iterate through in Js (like the thing above), as this is a data type, we don't need ""
<script>
fullJsonPayload = [Action.JsonResult];
</script>
If you chose a key (theKey) from a JsonResult, it outputs a comma separated list of results e.g. {},{}, so you might need to encapsulate the result in [] so that after parsing, when JS runs, it appears right.
<script>
arrayOfAnswers = [[Action.JsonResult | "theKey"]]
</script>
The best tool for checking is your browser buildin devtools inspector, you can open an Alert widget and inspect the HTML to see how the data rendered.