Many application API provides you the data in the form of JSON, so you can grab a piece of data you want and create a little application.

Today I will search the ticket according to the status, and show these tickets on the TV information board.

  • Ticket system: ManageEngine Servicedesk plus
  • scripting language: powershell
  • information publishing system: onelan digital signage

In the ticket, we have a status “Ready for collection”, once the laptop is fixed and ready for collection, we want the name to be shown on the TV information board.

Install IIS in the Windows Server

 

Install-WindowsFeature -name Web-Server -IncludeManagementTools

browse to C:\inetpub\wwwroot\ and delete all files.

Get JSON data in the service desk plus:

Follow the below steps to get an API key, https://help.servicedeskplus.com/api/rest-api.html

Login your service desk, Click Admin at the top bar, then find API under General Settings, then click Documentation, to open a new window.

Browse to Request > Request > View all Requests, under Input Data type below:

{
   "list_info": {
   "row_count": 20,
   "start_index": 1,
   "sort_field": "created_time",
   "sort_order": "asc",
   "get_total_count": true,
   "search_fields": {
      "status.name": "Ready for Collection"
   }
  }
}

If you click Try Now, it will show you the search result, then click Sample Scripts at the top. select the powershell, you will get:

$url = "https://your.domain.name/api/v3/requests"
$technician_key = @{ 'technician_key' = 'xxxxxxxxxxxxxxxxxxxxxxxxxx'}

#change the status.name into the one you want.

$input_data = @'
{
    "list_info": {
      "row_count": 20,
      "start_index": 1,
      "sort_field": "subject",
      "sort_order": "asc",
      "get_total_count": true,
      "search_fields": {
        "status.name": "Ready for Collection"
      }
    }
}
'@
$data = @{ 'input_data' = $input_data}
$response = Invoke-RestMethod -Uri $url -Method get -Body $data -Headers $technician_Key -ContentType "application/x-www-form-urlencoded"
$response

If you replace the your.domain.name with your service desk server URL, and replace the xxxxxxxxxxxxxxxxxxxxxxxxxx with your API key.

Up to now, you have all the data in the variable $response.

you should get something in the like below:

Extract the data we want

You can get the structure with an online tool: https://jsoneditoronline.org/

We want to get the name, which is nested under requests > requester.

So I created the below loop to get the data in the format of HTML table, I also added the HTML head and body, and let it refresh every 30 seconds:

for(;;) {

$response = Invoke-RestMethod -Uri $url -Method get -Body $data -Headers $technician_Key -ContentType "application/x-www-form-urlencoded"


#Extract the requester field from the JSON data

$requesters=$response.requests

$messagebody='<!DOCTYPE html PUBLIC" "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Laptop Pickup List</title>
<meta http-equiv="refresh" content="60">
<style>
body {font-family: "Raleway";font-size: 22px;}
h1{font-size:30px;}
td {text-align: left;} table {font-size:20px;font-weight:700;line-weight:70px;}
</style>
<link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<h1>Laptops are ready to pick up:</h1>
<table>'

foreach($requester in $requesters)
{



$messagebody = $messagebody + "<tr><td>" + $requester.requester.name +'</td><td><i class="fa fa-check-square" style="color:#228B22;margin-left:10px"></i></td></tr>'

}
$messagebody = $messagebody + "</table></body></html>"

$messagebody | out-file C:\inetpub\wwwroot\index.html

#Sleep 30 seconds before next loop.

Start-Sleep 30
}

Save the script as c:\scripts\pickup_list.ps1

Schedule the script:

Create a Task with a trigger:

  • Begin the task: at task creation/modification
  • enabled

Action:

  • Start a program: powershell
  • Add arguments: -File “C:\scripts\pickup_list.ps1”

 

Now if you open a browser, and type the server IP address or URL, you should see the list of the user.

 

 

 

Create a Onelan HTML layer

In the Onelan, add a HTML layer in one of the layout, then in the play list, add the url.

Publish it to the subscribers (TV with the onelan unit.)