Cool Solutions

Customizing the BSM implementation with java script



By:

July 2, 2010 3:33 pm

Reads:2,898

Comments:0

Score:Unrated

From time to time I get questions around customizing a BSM and/or CMDB implementation. Our product supports customization in many areas, so in order to jump right to the topic, I’ll skip over the areas and general how-to’s, why-to’s, etc for custom right-clicks, automation, computed property fields, etc. I’ll just get at the technical details of scripting.

To start with, we leverage java scripting as the approach for customizing. Most people (and formal training courses) use web development as the use case and the syntax, while similiar, it is slightly different. Our use of java scripting is more accurately compared to compiled java programming as opposed to web development. So when customers who want to do heavy customizations ask for training, while we provide training on where customization options exist and some examples, it is best to start out with “java” development training. From there, it is a matter of learning the objects that are exposed within our customization areas such as elements, alarms, attributes, relationships, etc.

In the example below, if you needed a script to get the current time, if you look at the standard java docs (http://java.sun.com/javase/6/docs/api/) you would see an example like the one below.

Java Example
Calendar currentTime = Calendar.getInstance();

The first challenge we run into is that the first part of the line of “Calendar currentTime” is not directly usable in java script, it needs adjusted.

Script version:
var currentTime = new java.util.Calendar.getInstance()

Once you get the currentTime variable set, you use it like you would in any standard java application.

if( currentTime.getTimeInMillis() <= helpDeskTicket.time )

If you run with the idea and you need to put a custom right-click in place that opens tickets to a home grown ticketing system, adds/updates rows to a database, sends an email, a page, etc, if you think about it, the bulk of the work is java and java scripting, only a small portion of the script is unique to the product.

Below are some general examples of how to access data.

Checking the name of a element and the condition before continuing on in the script

if( element.name.equals( “People Soft” ) && element.condition.equals( formula.severities.CRITICAL ) )

For an element, one of the children, one of the alarms and a property on the alarm called Application.

var appName = element.children[ i ].alarms[ j ][ 'Application' ]

This one always made me laugh: element.children[ i ].parent.name
okay, it is not that funny, it goes to the current element, down to one of the children and then asks for it’s parent name, so element.name is the same thing :)

Java Script is available in many areas of the product. Care should be taken when implementing scripts. Does it need to run on the server, on the client, memory considerations, opening and closing connections to databases, could it slow down the processing of automation events, will it cause long calculations for algorithms, etc.

Have fun and remember, the production server is not a play ground. Set up a good working environment in a test/dev lab and work through all the issues and use cases before going live into production.

0 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 5 (0 votes, average: 0.00 out of 5)
You need to be a registered member to rate this post.
Loading ... Loading ...

Categories: Uncategorized

Disclaimer: This content is not supported by Novell. It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test it thoroughly before using it in a production environment.

Comment

RSS