Scripts of the 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, case 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 case, 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 case comments are:

Steps to use a news s script:

  1. Write a script of the type News publisher on the Scripts page.
  2. Assign the script in the news configuration:
    1. Web Client: Assign the script to the news widget in the page customization (see News widgets).
    2. CM/Track: Reference the script in the portal configuration (see Widgets 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 7: Pseudocode to create news items from an RSS channel

Coding example 2: Retrieving news from case comments

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

Set queues = ["ServiceDesk"]

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

Set textClasses = ["Solution"]

return newsService.getNewsFromTicketEntries(queues, scopes, textClasses)

Code example 8: Script to retrieve news from case 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.