Scripts of Type News Publisher

Scripts of the type News publisher are used to determine which news are displayed on the Web Client dashboard and/or on the welcome page of CM/Track. The news which are returned by the script can be retrieved from several sources, for example, ticket comments or RSS feeds, or created directly within the script.

The news script returns a list of news items to be displayed in the Web Client or CM/Track. There are two ways of creating this list:

If you use getNewsFromTicketEntries, you need to define the following in the news script:

From each ticket, the latest comment marked with one of the text classes is displayed in the news. Only history entries of the type comment can be used in news scripts. If any other entry, for example an email, is marked with the configured text class, the entry is ignored.

The default values for news items from ticket comments are:

Steps to use a news script:

  1. Write a script of the type News publisher in the Scripts section of the Admin Tool.
  2. Assign the script in the news configuration:
    1. Web Client: Assign the script to the news widget in the page customization (see Attributes for News Widgets).
    2. CM/Track: Reference the script in the client configuration of the welcome page (see Displaying News on the Welcome Page)
  3. Adapt the default values for displaying news in the news configuration (optional).

Coding Example 1: Pseudocode to Retrieve News

The following pseudocode example shows how to build a list of NewsItems from an RSS channel.

def newsList = []

def url = "myurl"

Locale.setDefault(Locale.US)

try{

def rss = new XmlSlurper().parseText(url)

rss.channel.item.each {

def date = new Date().parse("EEE, dd MMM yy HH:mm:ss", "${it.pubDate}".substring(0, 23))

newsList.add(new NewsItem("${it.title}" as String, null, "${it.description}", date, null, null))

}

}catch(Exception e){

newsList.add(new NewsItem("No response from server" as String, ""))

}

return newsList

Code example 76: Pseudocode to create news items from an RSS channel

Coding Example 2: Retrieving News from Ticket Comments

The following example shows a script of the type News publisher used to retrieve news from ticket comments:

Set queues = ["ServiceDesk"]

Set scopes = ["defaultScope/Service_Desk/Work_in_progress"]

Set textClasses = ["Solution"]

return newsService.getNewsFromTicketEntries(queues, scopes, textClasses)

Code example 77: Script to retrieve news from ticket entries

The script retrieves the entries as objects of the class TicketEntryNewsItem. It is possible to extract data from the retrieved entries and modify them as desired.