0% found this document useful (0 votes)
123 views

Service Catalog Jython Validation

The document discusses validation scripting capabilities in Service Catalog. Validation scripts can be used to validate attribute values, offerings, and carts. Attribute validation scripts validate individual fields, while offering validation scripts run at different times like when adding to the cart or submitting the cart. Cart validation scripts run when the entire cart is submitted. The document provides details on the different types of validation scripts, their inputs and outputs, and how to return results from the scripts.

Uploaded by

yerberos86
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
123 views

Service Catalog Jython Validation

The document discusses validation scripting capabilities in Service Catalog. Validation scripts can be used to validate attribute values, offerings, and carts. Attribute validation scripts validate individual fields, while offering validation scripts run at different times like when adding to the cart or submitting the cart. Cart validation scripts run when the entire cart is submitted. The document provides details on the different types of validation scripts, their inputs and outputs, and how to return results from the scripts.

Uploaded by

yerberos86
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Service Catalog Script Validation

1 Service Catalog Validation Scripting

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.

1.1 Attribute Validation


Attribute validation is defined in the Offerings application on the Specification tab.
Validation of attributes can be used in several ways. It can be used to validate a
value entered in the field. The IPADDR validation script, for example, ensures
the value entered by the user is a valid IP Address; that it consists of 4 numbers,
3 dots, and the numbers are in the range of 0-255.

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.

1.2 Offering Validation


Offering validation is defined on the Offerings application, in the Validation Script
section. There are 3 types of offering validation.
o Pre-population – This script is run prior to the offering dialog being
displayed. The PREPOPUSER example script retrieves the logged in
user from the system, and populates the CONTACT field, so the dialog is
displayed initially with this value filled in.

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.

Figure 1 - Organization option to specify the Submit cart validation routine

This validation can be used to ensure that co-requisite or co-dependent offerings


are included in the same cart. The SUBMITCARTVAL routine is an example of
validation that can be done at the cart level. It checks to see that if the ‘INSTDB’
value on the Build Server with Middleware option is ‘yes’, that the Add DB to
Server offering is also in the cart.
1.4 Inputs and Outputs

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

Table 1 - Validation scripting inputs and outputs


1.5 Returning from the script
To return information from the script use the Jython 'print' function. For example
to return success from a script you can end your script with
print True (or print 1)

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.

You might also like