Script/Launch point creation
Script and Launch point creation are done using wizards that are available from the List tab in the Automation Script application. You can launch the Automation Script application from the GoTo → System Configuration → Autoscript menu. In the List tab drop down actions list, you can see the following wizards:
|Create a vanilla script without any launch point.|
|Create scripts with Object launch point.|
|Create scripts with Attribute launch point.|
|Create scripts with Action launch point.|
|Create scripts with custom condition launch point.|
|Create scripts for Integration.|
These wizards will guide you through the process of creating a script and optionally associating launch points with it. Launch points are discussed in detail in a later section.
Script and launch point maintenance
After the script and launch point has been created, you can use the Automation Script application for maintenance. Maintenance can be done using the Main, Variables, Launch point tabs in the Automation Script application. You can add or update the variables and their bindings as well as the bindings at the launch point level, if they are overridable. You cannot delete variables unless none of the launch points refer to that variable.
Variables and bindings
Scripts use variables to interact with Maximo.
Variables are either IN, INOUT, or OUT. These variables follow the classical definition where IN is the pass-by-value, and INOUT and OUT are passed by reference.
The script can modify only the INOUT and OUT variables.
Modifying IN variables in the script has no impact outside the script.
Variables can be bound to a Maximo artifact including a mbo attribute, a maxvar, and a maximo system property or
can be bound to a literal value which is not related to any Maximo artifact.
Variables bound to a maxvar or a system property are always IN variables as the script cannot modify them.
Variable data type for mbo attributes is driven by the mbo attribute datatype.
For example, a variable bound to Purchase Order MBOs totalcost attribute will inherit its type.
Variables bound to maxvar and system properties are always String variables.
You can define the data type of variables bound to literal values by specifying “literaldatatype” attribute in the autoscriptvars
table. The supported literal data types are ALN, INTEGER, SMALLINT, DECIMAL, YORN, DATETIME, and FLOAT.
You can define variable bindings at the script level or the launch point level if the definition at the script level
allows override of that value at the launch point level.
Another important aspect of the OUT and INOUT variables is how their values can be set back to the MBOs. You can set MBO attributes with the NOACTION flag, which determines if modifying the value of the MBO attribute will call the field validations action routine. You can also set MBO attributes with the NOVALIDATION flag, which determines if modifying the value of the MBO attribute will call the field validations validate routine. You can use MBO atributes to set the NOACCESSCHECK flags, which determine if the Action/Validation routine of the MBO attributes are called. You can set an MBO attribute with any combination of these flags. You can enable these settings from the script or launch point creation wizards and Automation Script application.
The following table explains their usage:
|Suppress Validation||Boolean||MBO attributes will be set with the NOVALIDATION flag, which determines if modifying the value of the MBO attribute will call the field validations validate routine (false) or not call the field validations validate routine (true).||For attribute bindings|
|Suppress Action||Boolean||MBO attributes will be set with the NOACTION flag, which determines if modifying the value of the MBO attribute will call the field validations validate routine (false) or not call the field validations validate routine (true).||For attribute bindings|
|Suppress Access Control||Boolean||MBO attributes will be set with the NOACCESSCHECK flag, which determines if the MBO attribute value can be modified irrespective of whether the attribute is readonly (true) or not (true/false).||For attribute bindings|
Implicit and explicit variables
Another important feature of scripting is implicit and explicit variables. Explicit variables are explicitly defined and bound in the variables page. Implicit variables are not explicitly defined in the variables page and are provided to you behind the scenes by the framework. Implicit variables follow the convention over configuration pattern where the framework will intelligently inject variables at run time which might otherwise have needed JAVA coding to fetch and set. Some implicit are injected based on how the explicit variables are defined and some are injected irrespectively. The following table lists and describes implicit variables.
|app||String||The name of the Maximo application which initiated the script execution.||All launch points dealing with an MBO or MBOSET|
|user||String||All launch points dealing with an MBO or MBOSET|
|mbo||psdi.mbo.Mbo||The current MBO in the context of the script execution. For example, in case of the Object Launch Point this will be the MBO, which is generating the events for the scripting framework. For attribute launch point this is the attributes owner MBO. For Action launch point this may be the Escalation or workflows MBO.||All launch points dealing with an MBO or MBOSET|
|mboname||String||The name of the current MBO in the context of the script execution.||All launch points dealing with an MBO or MBOSET|
|errorkey||String||This variable is for throwing MXExceptions from the script without having to explicitly import or refer to that API. This refers to the error key in the MXException. It works together with the errorgroup and the params implicit variables. The MXExceptions API is the standard way to throw Exceptions from Maximo-based components. The exception message is translated, which is the main advantage of using this API instead of a standard Java Exception, which is not going to be translated. Its usage is deprecated and replaced by the ||All launch points|
|errorgroup||String||Its usage is the same as the errorkey. It points to the error group of the MXException. Together with the errorkey it helps uniquely point to an error message in the Maximo message repository. Its usage is deprecated and replaced by the ||All launch points|
|interactive||boolean||It is a boolean variable indicating whether the script is executed in an interactive or UI session [value true] or a background session [for example, Integration]. This reflects the value of ||All launch points|
|evalresult||boolean||This is a boolean variable of type OUT to indicate the result of the condition evaluation.||Condition launch point and publish channel event filters|
|onadd||boolean||This boolean variable indicates whether the MBO in the script is added [new MBO – value true] or not. The script developer can use this for conditional actions or validations based on the state of the MBO.||All launch points or callbacks where MBO/MBOSET is involved. Mostly useful for Object launch point|
|onupdate||boolean||Boolean variable indicates where the MBO in the script is updated [exiting MBO – value true] or not. The script developer can use it for conditional actions or validations based on the state of the MBO.||All launch points or callbacks where MBO/MBOSET is involved. Mostly useful for Object launch points|
|ondelete||boolean||Boolean variable indicating whether the MBO in the script context is deleted [value true] or not.||All launch points or callbacks where mbo/mboset is involved. Mostly useful for Object launch point|
|action||String||The name of the Action that was generated from the Action Launch Point wizard.||Action Launch Point|
|scriptName||String||The name of the Script that is executed.||All Launch points|
|launchPoint||String||The name of the launch point for which the script is executed.||All Launch points|
|scriptHome||psdi.mbo.Mbo||This is the same as the implicit variable ||Action Launch points|
|wfinstance||psdi.workflow.WFInstance||The workflow instance MBO.||Action Launch Point – only when the Action is launched from a workflow.|
|service||com.ibm.tivoli.maximo.script.ScriptService||The global implicit var available to all scripts.||All Launch points and callbacks|
|listMboSet||psdi.mbo.MboSetRemote||This is used for setting the lookup MBOSET from a lookup script in attribute launch point.||Attribute Launch points - lookup scripts.|
|srcKeys||String||Used for mapping lookup MBO key to target MBO key (||Attribute Launch points - lookup scripts.|
|targetKeys||String||Used for mapping target MBO key to lookup MBO key (||Attribute Launch points - lookup scripts.|
Some implicit variables are injected into the script based on the explicitly defined variables. The following table describes the implicit variables that are based on explicitly defined variables whose binding type is an MBO attribute. There are no implicit variables for explicitly defined variables of other binding types like Literals, Maxvars, and System properties. The assumption is that “var” is the explicitly defined variable that binds to an MBO attribute.
|var_required||boolean||Required flag of the MBO attribute that var binds to.||All launch points. The script can modify it if the var is OUT or INOUT.|
|var_readonly||boolean||Readonly flag of the MBO attribute that var binds to.||All launch points. The script can modify it if the var is OUT or INOUT.|
|var_hidden||boolean||Hidden flag of the MBO attribute that var binds to.||All launch points. The script can modify if the var is OUT or INOUT.|
|var_internal||Same type as the MBO attribute to which var binds to.||For synonym domain kind of MBO attributes [like status] this represents the internal [maxvalue] value for the MBO attribute.||All launch points. Applicable only if var is bound to a MBO attribute that binds to a synonym domain. The script cannot modify it.|
|var_previous||boolean||The previous value of the MBO attribute ie the value just before the attribute value got changed.||Attribute launch points – applicable only for the attribute that generated the event. The script cannot modify it.|
|var_initial||boolean||The initial value of the MBO attribute ie the value assigned to that attribute when the MBO was initialized.||All launch points. The script cannot modify it.|
|var_modified||boolean||Indicates whether the MBO attribute to which the variable var binds to has been modified or not.||All launch points. The script cannot modify it.|
Launch points and callbacks
Launch points are application customization points. Launch points define which application artifact the user wants to customize by attaching the script to that point. In effect, the script is executed in the context of a launch point. For example, if you want to customize the Asset MBO’s initialization routine, use the key words Asset MBO & initialization routine. Another example is if you want to customize the Asset MBO’s purchaseprice attribute field validation routine. The key words that define the launch point are - Asset MBO, purchaseprice attribute, and field validation routine. Essentially, a launch point is a configuration to identify the application point to customize. A script can be associated with one or more launch points simultaneously. For example, a generic site-level validation script can be associated with all site level objects where each association is defined as an individual launch point. A script can be associated with a single launch point. For example, a script associated with the Object launch point cannot be associated again with another attribute launch point. After the first association is Completed between a script and a launch point – all subsequent launch points have to be the same type as the first.
The following launch points are currently supported by the scripting framework:
- MBO initialization and save point logic or Object launch point
- MBO attribute value modification – validation and action logic or Object attribute launch point
- Actions, which are used by many other components like Workflow, Escalation, UI Menu, UI Buttons or Action launch point
- Custom conditions used by Workflow conditions, Conditional UI and others or custom condition launch point.
Note: Launch points and callbacks are the first artifacts to consider when customizing an application.
Activating and deactivating scripts
Scripts can be activated or deactivated from the Launch Point tab of the Automation Scripting application or from the Script main page. The deactivation from the main script will deactivate the script for all launch points of that script. Deactivating from launch point only deactivates that particular launch point. All other active launch points should continue working as usual.
Maximo will not invoke a deactivated script. For example, if an Attribute launch point is deactivated, the script for that launch point will not be invoked if the value of that MBO attribute changes. Activating and deactivating scripts is a very useful tool for debugging issues with the application behavior and can take the script out of the equation temporarily to test the application without customization. The autoscript status attribute value has no significance on how the scripting framework will or will not invoke the script.