Creating a new script
The Automation Scripts application allows you to use Jython or Javascript to attach validation scripts to the Service Catalog at the attribute, offering, and cart levels.
Procedure
- Go to System Configuration > Platform Configuration > Automation Scripts.
- Click the Create Script action.
- Type a name for the script in the Script field.
This field is required. You can also, optionally, enter a description.
- Specify a value for Script Language.
- Type or copy and paste your script code into the Source
field.
Note:
For the validation scripts that have access to offering attributes, which are the fields on the dialog, there are two methods to get and save values.
To retrieve the value of a attribute in the dialog, use the getValue method. For example, for an offering dialog that has an IPADDR attribute, you could use the following to populate the ipaddr variable with the value of the IPADDR field on the dialog:ipaddr = offeringAttributes.getValue("IPADDR")
To set the value on the dialog of an attribute, use the setNewValue method. The first parameter is the name of the attribute, and the second is the value to put in the field:offeringAttributes.setNewValue("DBDIR", "c:/ibm/db2")
- To test your script, click the Execute Script icon. The Script Results dialog is displayed.Note: Executing the script does not allow you to test the script working in the Service catalog environment, but it does allow you to catch any syntax errors in your script.Note: Jython determines blocks by indentation, and the execute script function will return a nonspecific "invalid decedent" message if it finds syntax or indentation errors.
- Click Close.
- Click the Change Status icon. The Change State dialog is displayed.
- Using the list next to the New Status field, change the status to
Production. A script can only be used by Service Catalog if it is in the Production state.
- Click OK.
- To specify a version for your script, type a version number in the
Version field. The Version field is optional.
- Click Save.