Page script samples
You can use page scripts to link between apps, select rows in a QRadar® table, and get the IP address of an asset.
How to link between apps
You use the setActiveTab(tabId,url)
function from the
qradar.js library to link between two apps that are installed on the same QRadar
Console.
For example, you want to link from MyApp1 to MyApp2. MyApp1 uses the following HTML template with a div tag that calls a JavaScript function:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>myApp1</title>
<script type="text/javascript" src="static/js/myApp2.js"></script>
</head>
<body>
<div onclick="somejs();">
Link to myApp2</div>
</body>
</html>
The somejs()
function in the static/js/myApp2.js file uses
the setActiveTab(tabId,url)
function from the qradar.js
library:
function somejs() {
alert('set active tab');
top.setActiveTab("myApp2_1057","plugins/1057/app_proxy/index");
}
The tabId parameter uses the following format:
areasID_applicationID
. The areas ID is the value of the id
field in the areas block of the myApp2 manifest.json
file.
plugins/<applicationID>/app_proxy/<areasURL>
.The applicationID is assigned when you install your app. You can use the POST /gui_app_framework/application_creation_task endpoint to retrieve the applicationID.
The areasURL is the value of the url field in the areas block of the following myApp2 manifest.json file.
"areas": [
{
"id":"myApp2",
"text":"myApp2",
"description":"The app I am linking to",
"url":"index",
"required_capabilities":["ADMIN"] }
],
How to get the selected rows in a table
To get all the selected rows in a table on a QRadar page, use the following code in your page script:
var selectedIds = getSelectedRowIds();
var grid = getGrid();
var store = grid.store;
var row = grid.row(selectedIds[0], true );
How to get the IP address of the selected asset from the Asset page
To get the IP address of the selected asset from the QRadar Asset tab use the following code in your page script:
var assetId = selectedRows[0].id;