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.
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.
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.