Action launch point
The Maximo actions framework has a built-in library of actions which can be run from workflows, escalations, user interface menus, buttons and many other components. However, you might need actions that aren't included in this library. Scripting addresses this concern as you can script an action by using Jython and JavaScript.
For example, you can use a scripted action to do some calculated meters for assets. To create a script with an action launch point, from the Automation Scripts application select
.Assume you want to calculate an Asset meter value based on some other meters associated with that Asset. For example, you want to calculate the value of the PRESSURE meter, based on the IN-PRESSUR and O-PRESSUR meter such that the last reading of the PRESSURE meter is the summation of the IN and O-PRESSUR meters readings. Assume that you choose to do it offline as opposed to in real time, for which you would have to use object launch points to trap meter modification events. One way to do offline actions repeatedly in IBM® Maximo® Manage is to use escalations, which are cron jobs that run a predefined action in the context of a Maximo business object (MBO). Instead of writing the action Java code you can use a script.
assetnum=:assetnum and siteid=:siteid and metername='IN-PRESSUR'
Relation name | Relation where |
---|---|
assetmeterop | assetnum=:assetnum and siteid=:siteid and metername=‘O-PRESSUR’ |
assetmeterp | assetnum=:assetnum and siteid=:siteid and metername=‘PRESSURE’ |
In the Automation Scripts application, click
. Define the action launch point.Though this task creates the action, you must attach that action to the escalation, workflow or the user interface button or menu. By default, the launch point name is used as the name of the action, but you can modify the value to suit your naming convention. However, it is better to avoid renaming it because of name confusion and conflicts later on. In the first step of the task you saw that the object name is optional, which is in line with the Maximo action framework where an action may or may not be associated with a Maximo object. In this case however, you want to specify the object as asset as the action is specific to the Asset MBO.
Variable name | Variable type | Binding |
---|---|---|
iplr | IN | assetmeterip.lastreading |
olr | IN | assetmeterop.lastreading |
plr | IN | assetmeterp.lastreading |
pnr | OUT | assetmeterp.newreading |
The iplr, or IN-PRESSUR meter's last reading, olr, or O-PRESSUR meter's last reading, and plr, or PRESSURE meter's last reading, are all of type IN as you require those values to calculate the pnr, PRESSURE meter's last reading. The pnr is of type OUT as you set it back to the PRESSURE meter MBO.
y=float(iplr)+float(olr)
if y!=float(plr):
pnr=str(y)
The if
check in the second line takes care of not updating the
pnr
value if the calculated value is the same as the plr
[PRESSURE
meter's last reading]. This calculation was implemented as an example. In real implementations it
can be any complicated mathematical calculation as per your business requirement, only limited by
the mathematical support provided by the scripting language of your choice.
exists (select assetnum from assetmeter where metername='IN-PRESSUR' and
assetnum=asset.assetnum and siteid=asset.siteid) and exists (select assetnum from assetmeter
where metername='O-PRESSUR' and assetnum=asset.assetnum and siteid=asset.siteid) and
exists (select assetnum from assetmeter where metername='PRESSURE' and
assetnum=asset.assetnum and siteid=asset.siteid)
Select the action for this escalation. The name of the action is the same as the launch point name unless you modified it. After you activate the escalation, the job is complete. The escalation runs the scripted action for all the assets with the three meters and the modified asset meter readings are saved and committed by the escalation framework.
If you had chosen to not attach the action to a Maximo object, the step when you specify the variables and bindings will not let you bind a variable to an MBO attribute. You can, however, use the literal, system property, and maxvar variable binding types. A use case for that might arise when you write a generic action that, for example, invokes a service, like a Web service, which is not specific to an MBO or you intend to do the script code based on direct usage of the MBO APIs and therefore, will not need the MBO attribute bindings.