Service Catalog Jython Validation
Service Catalog Jython Validation
Service Catalog uses the new Automation Scripts application that is now part of
the base Maximo product to manage Jython scripts which can be used to
validate objects. There are a set of sample Jython validation routines shipped
with the Service Catalog. The sections below detail the validation available on
the attribute, offering and cart objects.
Another use of attribute validation is the ability to update or populate fields based
on the values of other fields. The INSTALLDB script checks for a ‘yes’ value in
the INSTDB field, and if that is found, it updates the values of the DBDIR and
DBADMIN fields with the specified values.
Note: The Pre-population script is run EVERY time the offering dialog is
opened. The script should take this into account, and check to see if the
field already has a value, before setting it.
o Add to cart – This script is run when the user clicks the ‘Add to Cart’
button on the offering dialog. The ADDTOCART example script checks to
see if the INSTMQ value is ‘yes’, and if it is, that the MQDIR is also filled
in. Add to Cart script processing runs all the attribute validation scripts
associated with this offering, and then runs the add to cart script specified.
o Submit cart – This script is run when the cart that this offering is in is
submitted. Each offering in the cart will run its Submit Cart script prior to
the cart being submitted successfully. Submit cart processing runs all the
'Submit Cart' scripts associated with the offerings in the cart, and then
runs the global 'Submit Cart' script, if one is defined.
The script writer should remember that validation scripts can run multiple times,
and incorporate that into the script logic. For example, the script should check if
a field already has a value, before setting it.
1.3 Cart Validation
In addition to the offering validation routines that are run when a cart is
submitted, there is also a global cart validation routine that can be run. This
routine is specified as an Organization Service Catalog option.
The Jython scripts have access to all Jython, Java and Maximo objects and
methods. The ‘scriptHome’ attribute that is passed to all scripts is a pointer to
the Maximo system, and can be used to retrieve additional information from
Maximo. The inputs also show, in parentheses, their Maximo object type.
The different script types have different inputs and outputs: Here is a table of the
inputs and outputs for the script types:
Object Type Inputs to Script Output Expected
Attribute Validation newValue - Value True (1) - script returned
type in by user successfully and data
(String); update newValue - Value
attribute - Name of entered by the user
attribute being (String)
validated (String); False (0) followed by an
offeringAttributes - error message or
All the attributes for message
this offering group/message key -
(PMSCCRSPEC) Script failed, and error
offering - The message will be
offering displaying displayed
the dialog (Offering) No return code - if the
cart - The cart this script is being used for
offering is currently in data update, do not
(PMSCCR) return a return code
scriptHome - A
pointer to Maximo
objects
Offerings Prepopulation offeringAttributes - The prepopulation script
All the attributes for does not process a
this offering return code
(PMSCCRSPEC)
offering - The
offering displaying
the dialog (Offering)
cart - The cart this
offering is currently in
(PMSCCR)
scriptHome - A
pointer to Maximo
objects
Add to Cart offeringAttributes - True (1) - script returned
All the attributes for successfully
this offering False (0) followed by an
(PMSCCRSPEC) error message or
offering - The message
offering displaying group/message key -
the dialog (Offering) Script failed, and error
cart - The cart this message will be
offering is currently in displayed
(PMSCCR)
scriptHome - A
pointer to Maximo
objects
Submit cart offeringAttributes - True (1) - script
All the attributes for returned successfully
this offering False (0) followed by an
(PMSCCRSPEC) error message or
offering - The message
offering displaying group/message key -
the dialog (Offering) Script failed, and error
cart - The cart this message will be
offering is currently in displayed
(PMSCCR)
scriptHome - A
pointer to Maximo
objects
Cart Submit cart cart - The cart this True (1) - script returned
offering is currently in successfully
(PMSCCR) False (0) followed by an
itemsInCart - array error message or
of items in the cart message
(an array of SRs) group/message key -
itemAttributes - an Script failed, and error
array of attributes (an message will be
array of displayed
PMSCCRSPECs)
scriptHome - A
pointer to Maximo
objects
For a failing script, you always print a 'False' or '0' first, followed by the error
message. For example, your script can end with
print False (or print 0)
print 'This script failed' Error messages always start with a '0'.
The text can be returned directly by the script, or a msggroup-msgkey format can
be used to pull a message from the MAXMESSAGES database table. If the
message comes back in the format MSGGROUP#MSGKEY[#parm1#parm2...]
then the MAXMESSAGES db will be search for the message. Optionally, any
parameters included in the return message will be applied to the message from
the database before it is displayed.