This will show you how to add a toolbar button for an Automation
script. I have included a “dummy” script that does not do much,
it is just to show you how to add a toolbar button to an application.
Create the script.
First go to Automation Scripting and create a new Action Launch Point.
For this purpose, I called my Launch Point MYSCRIPT and left the Action to MYSCRIPT as well.
Notice that I picked ASSET for my object, I plan to add this button to
the Asset Application. I then select a name for my actual script,
I just left it as MYSCRIPT but changed the debug level to DEBUG.
Add your code to the next dialog box and create the Launch Point. If
you do not have a code to test with, here is a piece of code that print
some
Work Orders in the log,
from psdi.server import MXServer
from java.text import SimpleDateFormat
sdf = SimpleDateFormat
fmt_out = sdf('yyyy-MM-dd HH:mm')
whereClause = "wonum in ('1000', '1001', '1002')"
mboMainSet = MXServer.getMXServer().getMboSet("workorder", MXServer.getMXServer().getSystemUserInfo())
mboMainSet.setWhere(whereClause)
mboMainSet.reset()
mainCount = 0
print "Running Automation Script."
while mboMainSet.getMbo(mainCount) is not None:
myMbo = mboMainSet.getMbo(mainCount)
mainCount = mainCount + 1
print "Work Order: " + myMbo.getString("wonum") + " " + myMbo.getString("description")
print "Status: " + myMbo.getString("status") + " " + fmt_out.format(myMbo.getDate("statusdate"))
This script shows you how to get a Mbo set from any object in Maximo
and also how to format a date in case you want a specific date format.
Add toolbar button to application
Go to Application Designer and bring up the Asset Application, bring up
the Add/Modify Signature Options dialog box from the Select Action
menu.
Click new row. Add your Action, make sure you expand the Advanced section and select the “Action” option.
Bring up the Add/Modify Toolbar Menu dialog box from the Select Action
menu. Click new row. Add your new Signature Security Option,
In this case, Tabs were chosen to be MAIN, if you want to be able to run the report from any tab, set it to ALL.
Enable toolbar button in Security Groups
Go to Security Groups and find your group that will be using this toolbar button, I used MAXADMIN in my demo database.
Bring up the Asset application and find “Run my script” and check it.
Save, sign out and sign in again with a user belonging to your group.
The icon will appear as a running man in the toolbar, right next to
create report.
Enable logging for the script
Clicking the Run My Script button does not do much since we set the Log
level to DEBUG. If you want to see the output in the log,
either change the logging level for Autoscript to DEBUG or change the
script log level to INFO. I chose to enable the DEBUG logging,
Set the Log Level to DEBUG, save and Apply Settings, the next time you
run the script you should see something like this in the log,