├── samples ├── original │ ├── AS03_01_poreccomm.md │ ├── AS04_worklog condition.doc │ ├── AS05_use sequence and not autokey(1).doc │ ├── AS01_Autoscript for setActualDates when comp wo.doc │ ├── AS03_Notify Users of Material and Service Receipts.docx │ └── AS02_Automation Script to make WF follow Status privileges as defined by Security Groups.docx ├── sample01 │ ├── SP01.png │ ├── SP02.png │ └── SP03.png ├── sample04 │ ├── pic1.png │ ├── pic2.png │ ├── pic3.png │ ├── pic4.png │ └── pic5.png ├── sample05 │ ├── pic1.png │ ├── pic2.png │ ├── pic3.png │ ├── pic4.png │ ├── pic5.png │ └── pic6.png ├── sample07 │ ├── pic1.png │ ├── pic2.png │ ├── pic3.png │ ├── pic4.png │ ├── pic5.png │ ├── pic6.png │ ├── 75_schedulingreports_with_automation_scripts.pdf │ └── POscript.py ├── sample08 │ ├── pic1.png │ ├── pic2.png │ ├── pic3.png │ ├── pic4.png │ ├── pic5.png │ ├── pic6.png │ └── lsnrwoact.pdf ├── sample11 │ ├── pic1.png │ ├── pic2.jpg │ ├── convertint.bat │ ├── convertint.sh │ ├── compsetactualdates.dbc │ ├── convert.bat │ └── convert.sh ├── sample06-1 │ ├── pic1.jpeg │ ├── pic2.jpeg │ ├── pic3.jpeg │ ├── pic4.jpeg │ └── datedifference.py ├── sample06-2 │ ├── pic1.jpeg │ ├── pic2.jpeg │ ├── pic3.jpeg │ ├── pic4.jpeg │ ├── pic5.jpeg │ └── pic6.jpeg ├── sample09 │ ├── pic1.jpeg │ └── pic2.jpeg ├── sample10 │ ├── pic01.gif │ ├── pic02.gif │ ├── pic03.gif │ ├── pic04.gif │ ├── pic05.gif │ ├── pic06.gif │ ├── pic07.gif │ ├── pic08.gif │ ├── pic09.gif │ ├── pic10.gif │ ├── pic11.gif │ ├── pic12.gif │ ├── pic13.gif │ ├── pic14.gif │ ├── pic15.gif │ ├── pic16.gif │ ├── pic17.gif │ ├── pic18.gif │ ├── pic19.gif │ └── pic20.gif ├── sample02 │ ├── Picture1.png │ ├── Picture2.png │ ├── Picture3.png │ ├── Picture4.png │ ├── Picture5.png │ ├── Picture6.png │ └── Picture7.png ├── AS01_scheduleDates.md ├── AS05_useSequence.md ├── AS04_workflowcondition.md ├── AS03_notifyUsers.md ├── AS02_makeWorkFlow.md ├── AS09_businessRule.md ├── AS07_executeReport_ReportExecution.md ├── AS06_dateCalculationP3.md ├── AS10_creatingAS.md ├── sample03 │ └── poreccomm.py ├── AS03_01_poreccomm.md ├── AS11_importExportScripts.md ├── AS06_dateCalculationP1.md ├── AS08_emailListener.md ├── AS06_dateCalculationP2.md └── AS07_executeReport.md ├── .travis.yml └── README.md /samples/original/AS03_01_poreccomm.md: -------------------------------------------------------------------------------- 1 | ls 2 | -------------------------------------------------------------------------------- /samples/sample01/SP01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample01/SP01.png -------------------------------------------------------------------------------- /samples/sample01/SP02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample01/SP02.png -------------------------------------------------------------------------------- /samples/sample01/SP03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample01/SP03.png -------------------------------------------------------------------------------- /samples/sample04/pic1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample04/pic1.png -------------------------------------------------------------------------------- /samples/sample04/pic2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample04/pic2.png -------------------------------------------------------------------------------- /samples/sample04/pic3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample04/pic3.png -------------------------------------------------------------------------------- /samples/sample04/pic4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample04/pic4.png -------------------------------------------------------------------------------- /samples/sample04/pic5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample04/pic5.png -------------------------------------------------------------------------------- /samples/sample05/pic1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample05/pic1.png -------------------------------------------------------------------------------- /samples/sample05/pic2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample05/pic2.png -------------------------------------------------------------------------------- /samples/sample05/pic3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample05/pic3.png -------------------------------------------------------------------------------- /samples/sample05/pic4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample05/pic4.png -------------------------------------------------------------------------------- /samples/sample05/pic5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample05/pic5.png -------------------------------------------------------------------------------- /samples/sample05/pic6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample05/pic6.png -------------------------------------------------------------------------------- /samples/sample07/pic1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample07/pic1.png -------------------------------------------------------------------------------- /samples/sample07/pic2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample07/pic2.png -------------------------------------------------------------------------------- /samples/sample07/pic3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample07/pic3.png -------------------------------------------------------------------------------- /samples/sample07/pic4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample07/pic4.png -------------------------------------------------------------------------------- /samples/sample07/pic5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample07/pic5.png -------------------------------------------------------------------------------- /samples/sample07/pic6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample07/pic6.png -------------------------------------------------------------------------------- /samples/sample08/pic1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample08/pic1.png -------------------------------------------------------------------------------- /samples/sample08/pic2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample08/pic2.png -------------------------------------------------------------------------------- /samples/sample08/pic3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample08/pic3.png -------------------------------------------------------------------------------- /samples/sample08/pic4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample08/pic4.png -------------------------------------------------------------------------------- /samples/sample08/pic5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample08/pic5.png -------------------------------------------------------------------------------- /samples/sample08/pic6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample08/pic6.png -------------------------------------------------------------------------------- /samples/sample11/pic1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample11/pic1.png -------------------------------------------------------------------------------- /samples/sample11/pic2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample11/pic2.jpg -------------------------------------------------------------------------------- /samples/sample06-1/pic1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample06-1/pic1.jpeg -------------------------------------------------------------------------------- /samples/sample06-1/pic2.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample06-1/pic2.jpeg -------------------------------------------------------------------------------- /samples/sample06-1/pic3.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample06-1/pic3.jpeg -------------------------------------------------------------------------------- /samples/sample06-1/pic4.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample06-1/pic4.jpeg -------------------------------------------------------------------------------- /samples/sample06-2/pic1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample06-2/pic1.jpeg -------------------------------------------------------------------------------- /samples/sample06-2/pic2.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample06-2/pic2.jpeg -------------------------------------------------------------------------------- /samples/sample06-2/pic3.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample06-2/pic3.jpeg -------------------------------------------------------------------------------- /samples/sample06-2/pic4.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample06-2/pic4.jpeg -------------------------------------------------------------------------------- /samples/sample06-2/pic5.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample06-2/pic5.jpeg -------------------------------------------------------------------------------- /samples/sample06-2/pic6.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample06-2/pic6.jpeg -------------------------------------------------------------------------------- /samples/sample09/pic1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample09/pic1.jpeg -------------------------------------------------------------------------------- /samples/sample09/pic2.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample09/pic2.jpeg -------------------------------------------------------------------------------- /samples/sample10/pic01.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample10/pic01.gif -------------------------------------------------------------------------------- /samples/sample10/pic02.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample10/pic02.gif -------------------------------------------------------------------------------- /samples/sample10/pic03.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample10/pic03.gif -------------------------------------------------------------------------------- /samples/sample10/pic04.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample10/pic04.gif -------------------------------------------------------------------------------- /samples/sample10/pic05.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample10/pic05.gif -------------------------------------------------------------------------------- /samples/sample10/pic06.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample10/pic06.gif -------------------------------------------------------------------------------- /samples/sample10/pic07.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample10/pic07.gif -------------------------------------------------------------------------------- /samples/sample10/pic08.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample10/pic08.gif -------------------------------------------------------------------------------- /samples/sample10/pic09.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample10/pic09.gif -------------------------------------------------------------------------------- /samples/sample10/pic10.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample10/pic10.gif -------------------------------------------------------------------------------- /samples/sample10/pic11.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample10/pic11.gif -------------------------------------------------------------------------------- /samples/sample10/pic12.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample10/pic12.gif -------------------------------------------------------------------------------- /samples/sample10/pic13.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample10/pic13.gif -------------------------------------------------------------------------------- /samples/sample10/pic14.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample10/pic14.gif -------------------------------------------------------------------------------- /samples/sample10/pic15.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample10/pic15.gif -------------------------------------------------------------------------------- /samples/sample10/pic16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample10/pic16.gif -------------------------------------------------------------------------------- /samples/sample10/pic17.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample10/pic17.gif -------------------------------------------------------------------------------- /samples/sample10/pic18.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample10/pic18.gif -------------------------------------------------------------------------------- /samples/sample10/pic19.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample10/pic19.gif -------------------------------------------------------------------------------- /samples/sample10/pic20.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample10/pic20.gif -------------------------------------------------------------------------------- /samples/sample02/Picture1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample02/Picture1.png -------------------------------------------------------------------------------- /samples/sample02/Picture2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample02/Picture2.png -------------------------------------------------------------------------------- /samples/sample02/Picture3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample02/Picture3.png -------------------------------------------------------------------------------- /samples/sample02/Picture4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample02/Picture4.png -------------------------------------------------------------------------------- /samples/sample02/Picture5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample02/Picture5.png -------------------------------------------------------------------------------- /samples/sample02/Picture6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample02/Picture6.png -------------------------------------------------------------------------------- /samples/sample02/Picture7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample02/Picture7.png -------------------------------------------------------------------------------- /samples/sample08/lsnrwoact.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample08/lsnrwoact.pdf -------------------------------------------------------------------------------- /samples/original/AS04_worklog condition.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/original/AS04_worklog condition.doc -------------------------------------------------------------------------------- /samples/original/AS05_use sequence and not autokey(1).doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/original/AS05_use sequence and not autokey(1).doc -------------------------------------------------------------------------------- /samples/sample07/75_schedulingreports_with_automation_scripts.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/sample07/75_schedulingreports_with_automation_scripts.pdf -------------------------------------------------------------------------------- /samples/original/AS01_Autoscript for setActualDates when comp wo.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/original/AS01_Autoscript for setActualDates when comp wo.doc -------------------------------------------------------------------------------- /samples/original/AS03_Notify Users of Material and Service Receipts.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/original/AS03_Notify Users of Material and Service Receipts.docx -------------------------------------------------------------------------------- /samples/original/AS02_Automation Script to make WF follow Status privileges as defined by Security Groups.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-maximo-dev/maximo-scripting/HEAD/samples/original/AS02_Automation Script to make WF follow Status privileges as defined by Security Groups.docx -------------------------------------------------------------------------------- /samples/sample11/convertint.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | SETLOCAL 4 | 5 | call commonEnv.bat 6 | 7 | set JAVA_HOME=..\..\java\jre 8 | 9 | rem Command line parameters are as follows 10 | rem -s represents source. Valid value is INT 11 | rem -n represents name (os name, es name ...). For multiple names use "," separation 12 | rem -a represents use header. Do you want bto create sigoption header. If multiple interaction for one application. Header need to be created only once 13 | rem -f represents file name. Must end with .ora, .sqs, .db2, .sql, .dbc. For dbc scripts use .dbc 14 | rem -p represents the password - value must be the password to access the e-mail account 15 | rem -u represents the user - value must be a valid e-mail account name 16 | rem -h represents host name (if not used will use localhost) 17 | %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sINT -nECRI -a0 -fecri.dbc -uwilson -pwilson -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | group: travis_latest 2 | language: python 3 | cache: pip 4 | matrix: 5 | allow_failures: 6 | - python: 2.7 7 | - python: 3.7 8 | include: 9 | - python: 2.7 10 | #- python: 3.4 11 | #- python: 3.5 12 | #- python: 3.6 13 | - python: 3.7 14 | dist: xenial # required for Python 3.7 (travis-ci/travis-ci#9069) 15 | sudo: required # required for Python 3.7 (travis-ci/travis-ci#9069) 16 | install: 17 | # - pip install -r requirements.txt 18 | - pip install flake8 19 | before_script: 20 | # stop the build if there are Python syntax errors or undefined names 21 | - flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics 22 | # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide 23 | - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics 24 | script: 25 | - true # add other tests here 26 | notifications: 27 | on_success: change 28 | on_failure: change # `always` will be the setting once code changes slow down 29 | -------------------------------------------------------------------------------- /samples/sample11/convertint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ./commonEnv.bat 4 | 5 | export JAVA_HOME="../../java/jre" 6 | export MAXIMO_CLASSPATH="../../../" 7 | 8 | echo $MAXIMO_CLASSPATH 9 | 10 | # Command line parameters are as follows 11 | # -s represents source. Valid value is INT 12 | # -n represents name (os name, es name ...). For multiple names use "," separation 13 | # -a represents use header. Do you want bto create sigoption header. If multiple interaction for one application. Header need to be created only once 14 | # -f represents file name. Must end with .ora, .sqs, .db2, .sql, .dbc. For dbc scripts use .dbc 15 | # -p represents the password - value must be the password to access the e-mail account 16 | # -u represents the user - value must be a valid e-mail account name 17 | # -h represents host name (if not used will use localhost) 18 | 19 | $JAVA_HOME/bin/java -cp "../classes:$MAXIMO_CLASSPATH:mail.jar:/$MAXIMO_CLASSPATH/applications/maximo/lib/*:/$1/applications/maximo/businessobjects/classes:." psdi.tools.DBCConverter -sINT -nECRI -a0 -fecri.dbc -umaxadmin -pmaxadmin -hlocalhost -------------------------------------------------------------------------------- /samples/AS01_scheduleDates.md: -------------------------------------------------------------------------------- 1 | # Automamtion script to set actual dates from scheduled dates when a work order is completed 2 | 3 | ## Setup: 4 | 5 | 1. In Maximo Asset Management, open the Automation Scripts application and create a script by selecting the **Create Script** action.. 6 | 2. From the menu, select the **Create > Script with Attribute Launch Point** action and specify the following information: 7 | ..* **Object** field: WORKORDER 8 | ..* **Atribute** field: STATUS 9 | ..* **Variable** field: status 10 | 11 | 12 | Automation Scripting - Schedule Dates 13 | 14 | 15 | Click **Next**. 16 | 17 | 3. In the script name field, enter COMPSETACTUALDATES. This name is used in the documentation for the [Import/Export an Automation Script](samples/AS11_importExportScripts.md) sample. 18 |
19 | 20 | 4. In the **Source Code** field, enter the following code and, if necessary, edit the term "COMP" to match the term that you use for the completed status: 21 | 22 | ```python 23 | ... 24 | if status=='COMP': 25 | mbo.setValue("ActStart", mbo.getDate("SchedStart") ) 26 | mbo.setValue("ActFinish", mbo.getDate("SchedFinish") ) 27 | ... 28 | ``` 29 | 30 |
31 | Automation Scripting - Schedule Dates 32 |
33 | 34 | To verify that the automation script works, in the Work Order Tracking application, change the status to complete. The actual dates should be set to scheduled dates: 35 | 36 | 37 |
38 | Automation Scripting - Schedule Dates 39 |
40 | -------------------------------------------------------------------------------- /samples/sample06-1/datedifference.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | from java.util import Calendar 3 | from java.util import Date 4 | from psdi.server import MXServer 5 | from java.sql import Statement 6 | from java.sql import PreparedStatement 7 | from java.sql import Connection 8 | from java.sql import ResultSet 9 | from psdi.mbo import Mbo 10 | 11 | 12 | mxserver = MXServer.getMXServer() 13 | userInfo = mxserver.getSystemUserInfo() 14 | currentSet = mxserver.getMboSet("MAXUSER",userInfo) 15 | currentMbo = currentSet.getMbo(0) 16 | con = currentMbo.getMboServer().getDBConnection(userInfo.getConnectionKey()) 17 | schema = currentMbo.getMboServer().getSchemaOwner() 18 | schema = schema.upper() 19 | currentDate = MXServer.getMXServer().getDate() 20 | userQuery = ['select userid, max(attemptdate) "LASTLOGINDATE" from logintracking where attemptresult = ','\'','LOGIN','\'', 'group by userid having max(attemptdate) <(sysdate-20)'] 21 | userQuery = ''.join(userQuery) 22 | s= con.createStatement() 23 | rs1 = s.executeQuery(userQuery) 24 | while(rs1.next()): 25 | date = rs1.getString ('LASTLOGINDATE') 26 | def calcelapsedtime(msdiff): 27 | secondinmillis = 1000 28 | minuteinmillis = secondinmillis * 60 29 | hourinmillis = minuteinmillis * 60 30 | dayinmillis = hourinmillis * 24 31 | elapseddays = msdiff / dayinmillis 32 | elapsedhours = msdiff / hourinmillis 33 | elapsedminutes = msdiff / minuteinmillis 34 | if(elapseddays !=0): 35 | return str(elapseddays) 36 | timediff = currentDate.getTime() - date.getTime() 37 | daydiff = calcelapsedtime(timediff) 38 | commSet = mxserver.getMboSet("COMMTEMPLATE",userInfo) 39 | commSet.setWhere("TEMPLATEID = 'XXX' ") 40 | commSet.reset() 41 | ctMbo = commSet.getMbo(0) 42 | if (ctMbo is not None): 43 | print(" inside if") 44 | ctMbo.setValue("SUBJECT","daydiff", MboConstants.NOVALIDATION_AND_NOACTION_AND_NOACCESSCHECK) 45 | ctMbo.sendMessage(mbo,mbo) 46 | 47 | rs1.close() 48 | -------------------------------------------------------------------------------- /samples/AS05_useSequence.md: -------------------------------------------------------------------------------- 1 | # Automation script to use a sequence instead of an autokey 2 | 3 | This script allows for the current unique id sequence to be used to set the record key value instead of using an autokey. Launch points can be created for various objects, such as work orders and tickets, and still use the same script. You can remove the autokey from the field in question. This example uses the **Reported By field** for the launch point, and it is recommended that you use the script for fields that do not require user entry. The script can further be expanded to process differently by site or based on the interactive flag. 4 | 5 | 6 | 7 | ### Step 1: Automation Script tab 8 | In the Automation Scripts application, select the **Create > Script with an Attribute Launch Point** action and paste the following script into the **Source Code** field on the **Automation Script** tab 9 | 10 | ```python 11 | key=str(id) 12 | ``` 13 | [Use Sequence](sample05/pic1.png) 14 | 15 | ## Step 2: Variables tab 16 | 17 | On the **Variables** tab, in the Variables section, expand the parentval variable and fill in the **Variable Type** field with the value IN. 18 | 19 | [Use Sequence](sample05/pic2.png) 20 | 21 | Find the variable key, exapnd it and fill in the **Variable Type** field with the value INOUT. 22 | 23 | [Use Sequence](sample05/pic3.png) 24 | 25 | Also, find the variable id, exapnd it and fill in the **Variable Type** field with the value INOUT, as shown in the following image: 26 | 27 | [Use Sequence](sample05/pic4.png) 28 | 29 | 30 | ## Step 3: Launch Points tab 31 | 32 | On the **Launch Point** Tab, verify that the launch point USESEQWO is listed and activated in the Launch Point section. 33 | 34 | [Use Sequence](sample05/pic5.png) 35 | 36 | Also, at the Attribute Launch Point section, verify that the **Attribute** field is set to REPORTEDBY value and tjat the variables are listed into the Launch Point Variables, as shown in the following image: 37 | 38 | [Use Sequence](sample05/pic6.png) 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /samples/AS04_workflowcondition.md: -------------------------------------------------------------------------------- 1 | # Automation script for a condition that is based on work log information 2 | 3 | This script returns a value of true or false based on the log type that is defined in a custom condition in the Conditional Expression Manager. 4 | 5 | ### Step 1 6 | 7 | In the Automation Scripts application, select the **Create > Script with an Object Launch Point** action. 8 | 9 | * On the **Automation Script** tab, copy and paste the following script source: 10 | ```kotlin 11 | if logtype == 'WORK': 12 | evalresult=True 13 | else: 14 | evalresult=False 15 | ``` 16 | 17 | [Work Flow Condition](sample04/pic1.png) 18 | 19 | ### Step 2 20 | 21 | * On the **Variables** tab, fill in the Script field with WORKLOGCOND variable name and uses the jython script as the Script Language to be used. Also, the Variable Type field must be IN and The Building Type value must as ATTRIBUTE, as shown in the following image: 22 | 23 | 24 | [Work Flow Condition](sample04/pic2.png) 25 | 26 | ### Step 3 27 | 28 | * On the **Launch Points** tab, verify the following values are specified: 29 | - In the **Script** field: WORKLOGCOND 30 | - In the **Script Language** field: jython 31 | - In the **Status** field: Draft 32 | Ensure that the launch point is listed in the "Launch Point" section, as shown in the following image: 33 | 34 | [Work Flow Condition](sample04/pic3.png) 35 | 36 | * In the "Custom Condition Launch Point" section, select the **Active** checkbox to TRUE and, in the ATTRIBUTE field, specify LOGTYPE. Then, click **OK** to proceed. 37 | 38 | [Work Flow Condition](sample04/pic4.png) 39 | 40 | ### Step 5 41 | 42 | * In the Conditional Expression Manager, create the condition by adding a row where the **Condition** field refers to LOGTYPE and the **Class** field contains the CLASS type. Also, in **Expression** field, paste in the following code: 43 | 44 | ```SQL 45 | worklogcond:worklogcond 46 | ``` 47 | The (Full Qualifiend Name) (FQN) of the Script Custom Condition class is given, and the **Class** field contains the following Java Type: 48 | 49 | ```java 50 | com.ibm.tivoli.maximo.script.ScriptCustomCondition 51 | ``` 52 | 53 | [Work Flow Condition](sample04/pic5.png) 54 | 55 | * The script verifies the values and returns a value of true or false. 56 | -------------------------------------------------------------------------------- /samples/sample11/compsetactualdates.dbc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 53 | 54 | -------------------------------------------------------------------------------- /samples/AS03_notifyUsers.md: -------------------------------------------------------------------------------- 1 | # Notify users of material and service receipts 2 | 3 | You can create an automation script that can notify users of receipts in an email, without sending a separate email for each receipt record. This process uses an escalation to activate a custom action to do send the notification. 4 | 5 | ## Prerequirements: 6 | 7 | This automation script was developed on Maximo Asset Management version 7.5.0.10 and SQL Server. 8 | 9 | 10 | ## Note: 11 | 12 | This automation script works only for purhcase orders where all lines are requested by the same user. 13 | 14 | ## Step 1 15 | 16 | Create a persistent attribute that is named PO.LASTRECDATE (DATETIME 10). 17 | 21 | 22 | ## Step 2 23 | 24 | Create a role that is named POREQ and specify the following information for the role: 25 | 30 | 31 | ## Step 3 32 | 33 | Create a communication template that is named PORECEIPT and specify the following information for the template: 34 | 40 | 41 | 42 | ## Step 4 43 | 44 | Create a custom launch point that is named PORECCOMM and specify the following information: 45 | 51 | 52 | ## Step 5 53 | 54 | Create an action group that is named PORECESC and specify the following information. 55 | 60 | 61 | ### Additional information: 62 | 63 | You can create new views on the database that are independent of Maximo Asset Management. 64 | 65 | * The following sample code can be used to update all PO records: 66 | 67 | ```kotlin 68 | V_PORECEIPTS 69 | ``` 70 | * The following sample code can also be used to update the V_MX_PORECEIPTS view: 71 | ```kotlin 72 | V_MX_PORECEIPTS (extra credit) 73 | ``` 74 | * The following sample code can be used as an imported Maximo object that combines MATREC and SERVREC by PO: 75 | 76 | PORECCOMM Script 77 | 78 | ## Step 6 79 | 80 | Create an escalation that is named PORECESC and specify the following information. 81 | 82 | 86 | 87 | ```sql 88 | 89 | po.historyflag = 0 AND po.receipts <> 'NONE' 90 | AND (exists (SELECT 1 FROM matrectrans mr WHERE mr.ponum = po.ponum AND mr.receiptref is NULL AND mr.issuetype = 'RECEIPT' AND mr.transdate > isnull(po.ns_lastrecdate,po.orderdate)) 91 | OR exists (SELECT 1 FROM servrectrans sr WHERE sr.ponum = po.ponum AND sr.receiptref is NULL AND sr.issuetype = 'RECEIPT' AND sr.transdate > isnull(po.ns_lastrecdate,po.orderdate))) 92 | 93 | ``` 94 | 95 | • Escalation Point: repeats 96 | • Action Group: PORECESC 97 | • Don’t forget to activate this SQL code. 98 | 99 | ## Sample script 100 | 101 | The following code contains the entire sample script for this scenario. 102 | PORECCOMM Script 103 | 104 | 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /samples/AS02_makeWorkFlow.md: -------------------------------------------------------------------------------- 1 | # Automation Script to make workflows follow the status privileges that are defined by security groups 2 | 3 | The default behavior of a workflow is to ignore security group privileges for status changes and other options. If a user who does not have the approval privilege for work orders set in the Security Groups application gets a work order that needs routed to them in a workflow, the workflow will ignore the fact that the user does not have the approval privilege and allow the user to approve the work order. Maximo Asset Management operates this way because the designer of the workflow process specifically sent the work order to this user for approval, so the approval is allowed. This behavior also allows Maximo administrators the flexibility to remove the change status privileges from the users so that they cannot change the status in the Work Order Tracking application but still can change the status by using a workflow. 4 | 5 | This automation script changes that default behavior. When this script is in place and active, a workflow will only allow the user to change the status if they have that status privilege granted to them in the Security Groups application. This script only changes the default behavior for status changes. The workflow will still ignore other Security Group provileges, such as creating a work order and allowing a user who does not have access to the Work Order Tracking application to create a work order in a workflow using the CREATEWO action. 6 | 7 | 1. Create an automation script that has an attribute launch point. This example uses a purchase order for the object and status for the attribute. 8 | 9 |
10 | Automation Scripting - Creating WorkFlow 11 |
12 | 13 | 14 | 2. Name the script. This example uses the name WFSTATUS. 15 |
16 | Automation Scripting - Creating WorkFlow 17 |
18 | 19 | 3. Paste the following code into the **Source Code** field: 20 | 21 |
22 | Automation Scripting - Creating WorkFlow 23 |
24 | 25 | Script Source: 26 | ```kotlin 27 | from psdi.mbo import MboConstants 28 | if not interactive and mbo.isModified("status") and onupdate: 29 | newstatus = mbo.getString('status') 30 | mbo.setValue('status', status_previous, MboConstants.NOACCESSCHECK | MboConstants.NOVALIDATION_AND_NOACTION) 31 | mbo.canChangeStatus(newstatus) 32 | mbo.setValue('status', newstatus, MboConstants.NOACCESSCHECK | MboConstants.NOVALIDATION_AND_NOACTION) 33 | ``` 34 | 35 | 36 | This example code adds the status privilege checking while in a work flow to purchase orders. 37 | 4. Optional: To add the code to an additional object, such as purchase requests, add an additional launch point on the **List** tab. Select the **Create > Script with Attribute Launch Point** action. After you specify the launch point information, select the radio button for using an existing script, specify the script name, WFSTATUS, and click **Next**: 38 |   39 |
40 | Automation Scripting - Creating WorkFlow 41 |
42 | 43 | 5. Click **Next** on Step 2 of the wizard and **Create** on Step 3 of the wizard. No changes are required for these steps. 44 | 45 | ### Automation Script tab: 46 | 47 |
48 | Automation Scripting - Creating WorkFlow 49 |
50 | 51 | ### Variables tab: 52 | 53 |
54 | Automation Scripting - Creating WorkFlow 55 |
56 | 57 | 58 | ### Launch Points tab (make one launch point for each object, such as PO or WO, that uses this script): 59 | 60 |
61 | Automation Scripting - Creating WorkFlow 62 |
63 | 64 | -------------------------------------------------------------------------------- /samples/AS09_businessRule.md: -------------------------------------------------------------------------------- 1 | # Turning a business rule by using scripting 2 | 3 | ## Work Order Tracking application - location and asset business rule 4 | 5 | In Maximo Asset Management, the Work Order Tracking application is one of the most heavily used business applications. In versions 5.x, 6.x and 7.x, the following business rule is automatically: Populate the **Asset** field if the Location that is selected for the work order contains only one asset. 6 | 7 | For many users, the auto-population of the **Asset** field is not useful. Most work orders are opened for a location, not an asset. When the **Asset** field is so populated by the application, users must consciously clear the entry before saving the work order record. An unwanted consequence of leaving the asset reference on the work order record is to have costs accrue to the wrong entity. 8 | 9 | ## "Turning off" the business rule 10 | 11 | You can effectively turn off the business rule by using automation scripts. A simple attribute launch point and associated automation script can clear the value that is populated into the **Asset** field. 12 | 13 | The attribute launch point and script are executed always after the standard business application field validation logic is executed. The job of the script logic is to determine whether the **Asset** field is empty or not, and if not empty, to set it to null. In the implementation, the script logic applies to a work order record that is newly inserted and n existing work order records that are modified. 14 | 15 | Clearing the **Asset** field has an effect on other fields and business rules in the Work Order Tracking application. For example, a safety plan that is associated with the combination of asset and job plan will not be applied when the asset field is cleared automatically. In this particular example, if a user subsequently enters the asset, then the safety plan business rule will be launched, as expected. 16 | 17 | ## WOASSETCLR launch point and script 18 | 19 | The following actions are required for the launch point and script implementation: 20 | 21 | * Define an attribute launch point by using the Automation Scripts application. 22 | * Specify that the business object is WORKORDER and the attribute is LOCATION. 23 | * Define an INOUT variable v_assetnum and bind it to the ASSETNUM attribute of the WORKORDER object. 24 | * Enter these lines of Jython code for the script: 25 | 26 | ```python 27 | ... 28 | if v_assetnum is not None: 29 | 30 | v_assetnum=None 31 | ... 32 | ``` 33 | 34 | * Save the launch point and script, and the launch point is already active. 35 | 36 | ## Testing the launch point 37 | 38 | If you have a product environment that has a location that is associated with a single asset, create a work order and select that location. When you tab out of the **Location** field, the **Asset** field remains empty. The following screen captures shows the effect of the launch point and script. 39 | 40 | Maximo Asset Management version 7.5 Work Order Tracking application with standard business rule (**Asset** field is populated): 41 | 42 | [Business Rules](sample09/pic1.jpeg) 43 |
Figure 1 Work Order Configuration
44 | 45 | Maximo Asset Management version 7.5 Work Order Tracking application with the WOASSETCLRlaunch point enabled (**Asset** field is cleared automatically): 46 | 47 | [Business Rules](sample09/pic2.jpeg) 48 |
Figure 2 Work Order Configuration
49 | 50 | ## Summary 51 | 52 | Automation scripts are an enabling component of the Maximo product architecture to incorporate business rules. However, in many cases, to incorporate business rules in the product, knowledge of the business application behavior is nrequired. Although only two lines of script code were needed to implement the turn off the business rule, a review of the implementation by a subject matter expert or experienced practitioner and testing in a development environment are essential before you make the business rule available to end users in a production environment. 53 | 54 | ## Useful Links 55 | 56 | [Automation Scripting Cookbook](http://ibm.co/pPl32E) 57 | -------------------------------------------------------------------------------- /samples/AS07_executeReport_ReportExecution.md: -------------------------------------------------------------------------------- 1 | # Report execution 2 | 3 | The Purchase Order application is supported by several reports, including Purchase Order Details and PO Status Details. This scenario uses the Purchase Order Details report as the report execute for this scenario. 4 | 5 | When a purchase order is selected on the **List** tab, the typical user-initiated report execution tasks are shown in the following table: 6 | 7 | 8 | 10 | 14 | 20 | 22 | 24 |
Task 9 | Description
1 11 | If **Run Reports** is available, click this action. 12 |
2 13 | In the Reports Selection window that appears, click the **Purchase Order Details Report**.
3 15 | In the Request Page window that appears, chose or specify the following: 16 | a. 17 | Schedule (Immediate, At This Time, Recurring) 18 | b. 19 | Email (Recipients, Subject, Comments, File Type, Report Delivery Format)
4 21 | On the Request Page window, click **Submit**.
5 23 | If report execution was scheduled to run
25 |
Table 1 Report execution tasks
26 | 27 | 28 | If the **Immediate** option was chosen, the report runs immediately, which opens the BIRT Report Viewer in a new browser window and displays details of the currently open purchase order. 29 | 30 | [Dizziness](sample07/pic1.png) 31 |
Figure 1 Details of a open purchase order.
32 | 33 | If the **Schedule | At This Time** option was chosen, then e-mail details, such as recipient, must be specified, and the report is executed in the background. Depending on the selected delivery option, a notification is sent to the recipient that includes the report as a PDF file, an Excel spreadsheet, or a live URL that can be clicked by the recipient as shown in Figure 2. 34 | 35 | [Dizziness](sample07/pic2.png) 36 |
Figure 2 Confirmation note
37 | 38 | Clicking the URL brings the user to a login page and after the user logs in, the Report Viewer is displayed. The Report Viewer shows a single entry that represents the executed report. A Download Content link enables the user to download the report as a PDF file or an XLS spreadsheet. 39 | 40 | [Dizziness](sample07/pic3.png) 41 |
Figure 3 Confirmation note
42 | 43 | A couple of important points must be noted: 44 | 1. The recipient of the report must have an active person record. 45 | 2. If the report is scheduled for execution at a later time, the selected time slot must be in the future. 46 | 47 | ## Scheduled report execution 48 | 49 | The following report execution options involve scheduling: 50 | * Running a report once in the future (The **At this Time** option) 51 | * Running a report on a recurring basis in the future (The **Recurring** option) 52 | 53 | After a report is scheduled, the following table shows the configuration records that drive report execution: 54 | 55 | 56 | 57 | 58 |
Report schedule recordUsed by the reporting framework to store the scheduling details for a report.
Cron task instance record for the REPORTSCHEDULE cron taskUsed by the Cron Task manager to execute the report on a schedule by placing a job into the report queue. The REPORTSCHEDULE cron task looks up the report schedule record to obtain details of the report execution.
59 |
Table 2 Report configuration
60 | 61 | When a report is run by using the **At This Time** option, the reporting framework prepares a one-time cron task instance that uses the REPORTSCHEDULE cron task. After the report is executed, this one-time instance record is removed from the Cron Task instance table. 62 | When the report is run by using the **Recurring** option, the reporting framework prepares a cron task instance that uses the REPORTSCHEDULE cron task. This cron task instance remains in the product environment until an administrator deletes the report schedule record by using the View Scheduled Reports user interface in Report Administration application. 63 | 64 | NOTE: The REPORTSCHEDULE cron task is a read-only cron task. To view it in the Cron Task Setup application, you must set the **Access Level** field to READONLY and search. 65 | -------------------------------------------------------------------------------- /samples/AS06_dateCalculationP3.md: -------------------------------------------------------------------------------- 1 | # JavaScript-based date calculation 2 | 3 | ## Introduction 4 | 5 | You can create a JavaScript-based script to calculate dates. 6 | 7 | 1 - In the Automation Scripts application, define a new action launch point and create the JavaScript-based script, which generates an action. 8 | 2 - In the Escalation application, update the SRDDESC escalation to point to the new action. 9 | 10 | ## New action launch point, action, and script 11 | 12 | All three entities, action launch point, action and script, are named SRDDACTIONJS, and the script language is ‘javascript’. Associate the same input and output variables: input variables – reportdate; output variables – targetcontactdate, targetstartdate. 13 | 14 | The JavaScript code is shown below. 15 | 16 | ```java 17 | function ISODateString (d) 18 | { 19 | function pad(n){return n<10 ? '0'+n : n} 20 | return d.getUTCFullYear()+'-' 21 | + pad(d.getUTCMonth()+1)+'-' 22 | + pad(d.getUTCDate())+'T' 23 | + pad(d.getUTCHours())+':' 24 | + pad(d.getUTCMinutes())+':' 25 | + pad(d.getUTCSeconds()) 26 | } 27 | 28 | println ('SRDDACTIONJS - script execution started'); 29 | var currentTime = new Date(reportdate.getTime()); 30 | currentTime.setDate(currentTime.getDate() + 1) ; 31 | targetcontactdate = ISODateString(currentTime); 32 | currentTime.setDate (currentTime.getDate() + 1); 33 | targetstartdate = ISODateString(currentTime); 34 | println ('SRDDACTIONJS - script execution complete'); 35 | ``` 36 | 37 | The basic logic in the script is based on using the reportdate to calculate the targetcontactdate and targetstartdate. Targetcontactdate is calculated to be 1 day from reportdate, and the targetstartdate is calculated to be 2 days from reportdate.The JavaScript Date object is the primary object that is used to calculate the required dates 38 | 39 | The following considerations must be accommodated: 40 | 41 | 1. The input variable reportdate is a Java-based Date object. It cannot be used as is with the JavaScript Date object. A JavaScript Date object can be initialized a number of ways. Initialize the JavaScript Date object as a value that represents time in milliseconds. Use the Java Date object’s getTime() method to obtain the ‘reportdate’ time value in milliseconds and construct the JavaScript Date object from that millisecond value. 42 | 2. Determine a suitable way of returning the calculated date that Maximo Asset Management can accept and set into the attributes of the target SR record. 43 | 3. Returning the value from a JavaScript Date.toDateString() or Date.toLocaleDateString() results in the following error: “BMXAA4144E - The date/time format is not valid. Make sure the date/time is specified in a valid format supported by the current locale setting”. 44 | 4. Returning the value from a JavaScript Date.getTime() results in the following error: “BMXAA7816E - Operation setValue(double value) is not supported on data type DATETIME. Report the error to your system administrator.” 45 | 46 | Maximo Asset Management requires date values to be to a certain format. One of the acceptable formats is a date time value that is represented in the ISO 8601 format. The ISODateString() in the sample script accepts the JavaScript Date object as parameter and constructs an ISO 8601-formatted date-time string. The ISO 8601 format is usually expressed in the following format: 47 | 48 | ```kotlin 49 | --T:: 50 | ``` 51 | 52 | or as: 53 | 54 | ```kotlin 55 | YYYY-MM-DDThh:mm:ss 56 | ``` 57 | 58 | In the function, the call to Date.getUTCMonth() is followed by a ‘+1’, because that method returns an integer between 0 and 11, and an integer between 1 and 12 is needed. 59 | 60 | By including a simple println() statement in the body of the script, you can view the output of the ISODateString() function. It is similar to the following output: 61 | 62 | ```kotlin 63 | 2011-12-26T04:37:33 64 | ``` 65 | The pad() function inside the ISODateString() function is used to place a zero to the left of the number (month, date, hours, minutes or seconds) if that number is below 10 to ensure the final string is ISO 8601-compliant. 66 | 67 | ## Testing the new script 68 | 69 | 1. In the Escalations application, open the SRDDESC escalation definition. 70 | 2. Deactivate the escalation, if needed, and then delete the SRDDACTIONJAVA action. 71 | 3. Associate the new action SRDDACTIONJS with the escalation. Save and activate. 72 | 73 | ## Summary 74 | 75 | Date calculations can be performed by using JavaScript’s Date object. The one drawback is the difficulty in formatting date and time strings, which can be overcome by writing simple functions. 76 | 77 | ## Useful Links 78 | 79 | [Maximo 7.5 Scripting Cookbook](https://www.ibm.com/developerworks/mydeveloperworks/blogs/a9ba1efe-b731-4317-9724-a181d6155e3a/entry/scripting_with_maximo6?lang=en) 80 | 81 | [Date Dizziness – Part I](AS06_dateDizzinessP1.md) 82 | 83 | [Date Dizziness – Part II](AS06_dateDizzinessP2.md) 84 | 85 | [Mozilla JavaScript Date object and methods](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date) 86 | 87 | -------------------------------------------------------------------------------- /samples/AS10_creatingAS.md: -------------------------------------------------------------------------------- 1 | # Creating and importing automation scripts by using the user interface 2 | 3 | After reading this document, you will know which events you can select when creating attribute launch points in Maximo Asset Management and how to import a .py script into the Automation Scripts application. 4 | 5 | The following events are available when you create the attribute launch point: 6 | 7 | The **Initialize Value** event is used to initialize the attribute for new records. 8 | 9 | The **Initialize Access Restriction** event is used to set an attribute as required or read-only when first the application is first accessed. 10 | 11 | The **Validation** event is used to validate the attribute. Do not add new variables to include business logic here. 12 | 13 | The **Run Action** event is used for all business logic that is associated with the attribute. Do not try to do validation here. 14 | 15 | The **Retrieve List** event is used when a domain is associated with the attribute. 16 | 17 | 18 | ## Requirements and samples 19 | 20 | The following requirements are used in this example: 21 | 22 | Requirement 1: A vendor is required when the asset type is Production in the Run Action event. 23 | 24 | Requirement 2: The purchase price must be between $20 - $20000 in the Validate event. 25 | 26 | Requirement 3: The replacement cost is always be one-half of the purchase price in the Run Action event. 27 | 28 | ### Steps: 29 | 30 | 1. Open the Automation Scripts application. 31 | 32 | From the action menu, click **Create** and select the **Script with Attribute Launch Point** action. 33 | 34 | [CreateAS](sample10/pic01.gif) 35 | 36 | 2. Specify values in the **Launch Point**, **Object**, and **Attribute** fields. 37 | 38 | Select the **Validate** event. 39 | 40 | [CreateAS](sample10/pic02.gif) 41 | 42 | Click **Next**. 43 | 44 | 3. Enter a name for the script and change the script language to 'jython'. 45 | 46 | [CreateAS](sample10/pic03.gif) 47 | 48 | Enter the following code in the **Source Code** field: 49 | ```python 50 | from psdi.util import MXApplicationException 51 | if purchaseprice < 20 or purchaseprice > 20000: 52 | errorgroup = 'custom' 53 | errorkey = 'outofrangeprice' 54 | ``` 55 | 56 | 57 | **Note:** THe errorgroup and errorkey lines must be indented, which is shown in the following image: 58 | 59 | [CreateAS](sample10/pic04.gif) 60 | 61 | Click **Next**. 62 | 63 | A system message is displayed. 64 | 65 | [CreateAS](sample10/pic05.gif) 66 | 67 | Click **Close**. 68 | 69 | 4. Open the Database Configuration application. 70 | Select the **Messages** action and click the **New Row** button. 71 | Specify values in the **Message Group**, **Message Key**, **Message ID Prefix**, and **Value** fields, as shown in the following image: 72 | 73 | [CreateAS](sample10/pic06.gif) 74 | 75 | Click **OK**. 76 | 77 | 5. Open the Automation Scripts application. 78 | From the action menu, click **Create**" and select the **Script with Attribute Launch Point** action. 79 | 80 | [CreateAS](sample10/pic07.gif) 81 | 82 | 6. Specify values in the **Launch Point**, **Object**, and **Attribute** fields and select the **Run Action** event. 83 | 84 | [CreateAS](sample10/pic08.gif) 85 | 86 | Click **Next**. 87 | 88 | 7. Click the **New Row** button to create another variable. 89 | Specify values in the **Variable**, **Variable Type**,**Binding Type** and **Launch Point Attribute** fields. In this example, the values are assetType in the **Variable** field, INOUT in the **Variable Type** field, ATTRIBUTE in the **Binding Type** field, and ASSETTYPE in the the **Launch Point Attribute** field, as shown in the following image: 90 | 91 | [CreateAS](sample10/pic09.gif) 92 | 93 | 8. Click the **New Row** button to create another variable. 94 | Specify values in the **Variable**, **Variable Type**, **Binding Type**, and **Launch Point Attribute** fields. In this example, the values are vendor **Variable** field, INOUT in the **Variable Type** field, ATTRIBUTE in the **Binding Type** field, and VENDOR in the **Launch Point Attribute** field, as shown in the following image: 95 | 96 | [CreateAS](sample10/pic10.gif) 97 | 98 | Click **Next**. 99 | 100 | 9. Enter the following source code: 101 | 102 | ```python 103 | if assettype_internal=="PRODUCTION": 104 | vendor_required=True 105 | else: 106 | vendor_required=False 107 | ``` 108 | 109 | **Note:** The _internal is an implicit variable that indicates that the asset type field is associated to a synonym domain. 110 | The _required is an implicit variable for setting mandatory fields. 111 | 112 | Your Source Code screen looks like the following image: 113 | 114 | [CreateAS](sample10/pic11.gif) 115 | 116 | Click **Create** to create the launch point. 117 | A system message is displayed. 118 | 119 | [CreateAS](sample10/pic12.gif) 120 | 121 | Click **Close**. 122 | 123 | 10. From the action menu, click **Create**" and select the **Script with Attribute Launch Point** action. 124 | 125 | Specify values in the **Launch Point**, **Object**, and **Attribute** fields and select the **Run Action** event. 126 | 127 | [CreateAS](sample10/pic13.gif) 128 | 129 | Click **Next**. 130 | 131 | 11. Click the **New Row** button to create another variable. 132 | Specify values in the **Variable**, **Variable Type**, **Binding Type**, and **Launch Point Attribute** fields. In this example, the values are replacecost in the **Variable** field, INOUT in the **Variable Type** field, ATTRIBUTE in the **Binding Type** field, and REPLACECOST in the**Launch Point Attribute** field, as shown in the following image: 133 | 134 | [CreateAS](sample10/pic14.gif) 135 | 136 | Click **Next**. 137 | 138 | 12. Enter a name for the script and enter the following source code: 139 | 140 | ```python 141 | if purchaseprice > 200: 142 | replacecost = purchaseprice/2 143 | ``` 144 | 145 | [CreateAS](sample10/pic15.gif) 146 | 147 | Click **Create**. 148 | A system message is displayed. 149 | 150 | [CreateAS](sample10/pic16.gif) 151 | 152 | Click **Close**. 153 | 154 | All three attribute launch points are created. 155 | 156 | ## Testing the attribute launch points 157 | 158 | 159 | ### Steps: 160 | 161 | 1. In the Assets application, open an existing asset. 162 | 2. Enter "Production" for the asset type. 163 | 164 | [CreateAS](sample10/pic17.gif) 165 | 166 | 3. Scroll down to check the **Vendor** field. 167 | Because the asset type is "PRODUCTION", the vendor field is mandatory as required by the "ASSETTYPE" attribute launch point. 168 | You can see that the **Vendor** field has an asterisk to indicate that it is a required field. 169 | 170 | [CreateAS](sample10/pic18.gif) 171 | 172 | 4. In the **Purchase Price** field, enter 1000 and tab out of the field. 173 | 174 | Because the purchase price exceeds 200, the Replacement Cost value is changed to 500. which is half of the purchase price as required by the "CALREPLACECOST" attribute launch point. 175 | 176 | [CreateAS](sample10/pic19.gif) 177 | 178 | 5. In the **Purchase Price** field, enter 50000. 179 | 180 | Click on the red cross to see the following error message: "BMXZZ0001E - Please enter a value between $20 and $20000 and then press Enter." 181 | 182 | [CreateAS](sample10/pic20.gif) 183 | 184 | Now you must click the **Edit My Value** button and enter a cost between $20 and $20000 as required by the "PURCHASEPRICE" attribute launch point. 185 | -------------------------------------------------------------------------------- /samples/sample03/poreccomm.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | # Custom Action Launchpoint PORECCOMM 3 | # Called from Escalation PORECESC 4 | # com.ibm.tivoli.maximo.script.ScriptAction 5 | # PORECCOMM,PORECCOMM,PORECCOMM 6 | # PO.LASTRECDATE is a custom attribute to reflect latest receipt date (MATREC or SERVREC) 7 | # Written against MX 7.5.0.10 8 | 9 | import java 10 | from java.util import Calendar 11 | from java.util import Date 12 | from psdi.server import MXServer 13 | from psdi.mbo import MboConstants 14 | from psdi.mbo import MboSet 15 | from com.ibm.tivoli.maximo.util.mbo import IterableMboSet 16 | servDT = MXServer.getMXServer().getDate() 17 | df = java.text.SimpleDateFormat("MM/dd/yy kk:mm") 18 | dfnow = java.text.SimpleDateFormat("kk:mm:s:S") 19 | today = MXServer.getMXServer().getDate() 20 | now = dfnow.format(today) 21 | today = df.format(today) 22 | 23 | def log(e): print(str(now) + ": "+str(launchPoint)+("__>> %s" % e) + "\r\n") 24 | print("*************") 25 | log("buffer") 26 | log("Entering Script:....."+str(now)) 27 | 28 | s_poNum = str(mbo.getString("PONUM") or None) 29 | s_poDesc = str(mbo.getString("DESCRIPTION") or None) 30 | s_poVend = str(mbo.getString("VENDOR.NAME") or None) 31 | s_poType = str(mbo.getString("POTYPE") or None) 32 | b_hasReceipts,b_sendComm = (False,)*2 33 | h_tableBody = "" 34 | d_lastRecDate = mbo.getDate("LASTRECDATE") or None # Custom attribute to display and reference on PO 35 | if(d_lastRecDate is None): d_lastRecDate = mbo.getDate("STATUSDATE") 36 | d_lastRec = d_lastRecDate 37 | d_newLastRec = d_lastRec 38 | 39 | # Some substitution variables to use in HTML 40 | h_left = " style=""text-align:left;""" 41 | h_size = " style=""font-size:90%;""" 42 | h_htmlHead = "" 43 | h_htmlFoot = "" 44 | h_tableBody = "" 45 | h_poHead = "

The following has been received from "+str(s_poVend)+" on PO:"+str(s_poNum)+"

"+str(s_poDesc)+"

" 46 | h_tableHead = "ItemDescriptionQuantity" 47 | h_tableFoot = "
" 48 | h_message = h_htmlHead 49 | 50 | # sendComm function 51 | def sendComm(s_templateId,s_subject,h_message): 52 | whereclause = "TEMPLATEID = '"+str(s_templateId)+"'" 53 | ctMboSet = mbo.getMboSet("$commtemp","COMMTEMPLATE",whereclause); 54 | ctMboSet.setQbeExactMatch("true") 55 | ctMboSet.reset() 56 | ctMbo = ctMboSet.getMbo(0) 57 | if(ctMbo is not None): 58 | ctMbo.setValue("SUBJECT",s_subject, MboConstants.NOACCESSCHECK | MboConstants.NOVALIDATION_AND_NOACTION) 59 | ctMbo.setValue("MESSAGE",h_message, MboConstants.NOACCESSCHECK | MboConstants.NOVALIDATION_AND_NOACTION) 60 | ctMbo.sendMessage(mbo,mbo); 61 | return 62 | 63 | s_matRecSql = " ponum = '"+s_poNum+"' and receiptref is NULL and issuetype = 'RECEIPT' and transdate > '"+str(d_lastRec)+"' " 64 | matRecSet = mbo.getMboSet("$MATREC$","MATRECTRANS",s_matRecSql) 65 | log("matRecSet.count(): "+str(matRecSet.count())) 66 | if(matRecSet.count() > 0): 67 | b_hasReceipts = True 68 | matRec = matRecSet.moveFirst() 69 | while(matRec is not None): 70 | d_mrTransDate = matRec.getDate("TRANSDATE") 71 | if(d_mrTransDate > d_newLastRec): d_newLastRec = d_mrTransDate 72 | s_toStoreLoc = matRec.getString("TOSTORELOC") or None 73 | if(s_toStoreLoc is None and s_poType == "STD"): 74 | s_itemNum = matRec.getString("ITEMNUM") or None 75 | s_itemDesc = (matRec.getString("DESCRIPTION") or None)[:65] 76 | s_itemQty = str(matRec.getFloat("QUANTITY")) 77 | b_sendComm = True 78 | h_tableBody = h_tableBody + ""+str(s_itemNum)+""+str(s_itemDesc)+""+str(s_itemQty)+"" 79 | matRec = matRecSet.moveNext() 80 | 81 | 82 | s_servRecSql = " ponum = '"+s_poNum+"' and receiptref is NULL and issuetype = 'RECEIPT' and transdate > '"+str(d_lastRec)+"' " 83 | servRecSet = mbo.getMboSet("$SERVREC$","SERVRECTRANS",s_servRecSql) 84 | log("servRecSet.count(): "+str(servRecSet.count())) 85 | if(servRecSet.count() > 0): 86 | b_hasReceipts = True 87 | servRec = servRecSet.moveFirst() 88 | while(servRec is not None): 89 | d_srTransDate = servRec.getDate("TRANSDATE") 90 | if(d_srTransDate > d_newLastRec): d_newLastRec = d_srTransDate 91 | if(s_poType == "STD"): 92 | b_sendComm = True 93 | s_servDesc = (servRec.getString("DESCRIPTION") or None)[:65] 94 | s_servQty = str(servRec.getFloat("QUANTITY")) 95 | h_tableBody = h_tableBody + "SERVICE"+str(s_servDesc)+""+str(s_servQty)+"" 96 | servRec = servRecSet.moveNext() 97 | 98 | 99 | log("*********") 100 | log("b_hasReceipts: "+str(b_hasReceipts)) 101 | log("b_sendComm: "+str(b_sendComm)) 102 | 103 | 104 | 105 | if(b_hasReceipts): 106 | log("Set PO.LASTRECDATE") 107 | mbo.setValue("LASTRECDATE",d_lastRec,MboConstants.NOACCESSCHECK | MboConstants.NOVALIDATION_AND_NOACTION) 108 | if(b_sendComm): 109 | log("Send Communication") 110 | s_templateId = "PORECEIPT" 111 | s_subject = "Receipts on PO: "+s_poNum+" "+str(df.format(d_lastRec)) 112 | # Build HTML for message 113 | h_message = h_message+h_tableHead+h_tableBody+h_htmlFoot 114 | sendComm(s_templateId,s_subject,h_message) 115 | 116 | log("Exiting Script") 117 | log("buffer") 118 | 119 | ''' SQL 120 | 121 | V_PORECEIPTS 122 | create view dbo.v_poreceipts (siteid,orgid,itemnum,description,glcreditacct,gldebitacct,issuetype,linecost,linetype,transid,mrlinenum,mrnum,polinenum,ponum,porevisionnum,quantity,receivedunit,refwo,remark,requestedby,status,transdate,unitcost,receiptref,owner,invoicenum,tostoreloc,packingslipnum,issue) as 123 | 124 | (SELECT mr.siteid,mr.orgid,mr.itemnum,mr.description,mr.glcreditacct,mr.gldebitacct,mr.issuetype,mr.linecost,mr.linetype,mr.matrectransid 'transid', 125 | mr.mrlinenum,mr.mrnum,mr.polinenum,mr.ponum,mr.porevisionnum,mr.quantity,mr.receivedunit,mr.refwo, 126 | mr.remark,mr.requestedby,mr.status,mr.transdate,mr.unitcost,mr.receiptref,'MATRECTRANS',mr.invoicenum,mr.tostoreloc,mr.packingslipnum,mr.issue 127 | FROM matrectrans mr 128 | UNION ALL 129 | SELECT sr.siteid,sr.orgid,'Service',sr.description,sr.glcreditacct,sr.gldebitacct,sr.issuetype,sr.linecost,sr.linetype,sr.servrectransid 'transid',sr.mrlinenum, 130 | sr.mrnum,sr.polinenum,sr.ponum,sr.porevisionnum,sr.quantity,pol.orderunit,sr.refwo,sr.remark,pol.requestedby, 131 | sr.status,sr.transdate,sr.unitcost,sr.receiptref,'SERVRECTRANS',sr.invoicenum,NULL,NULL,1 132 | FROM servrectrans sr LEFT JOIN poline pol ON sr.ponum = pol.ponum AND sr.polinenum = pol.polinenum AND sr.porevisionnum = pol.revisionnum) 133 | 134 | V_MX_PORECEIPTS 135 | create view dbo.v_mx_poreceipts (siteid,orgid,itemnum,description,glcreditacct,gldebitacct,issuetype,linecost,linetype,transid,mrlinenum,mrnum,polinenum,ponum,porevisionnum,quantity,receivedunit,refwo,remark,requestedby,status,transdate,unitcost,receiptref,owner,invoicenum,tostoreloc,packingslipnum,issue) as 136 | SELECT siteid,orgid,itemnum,description,glcreditacct,gldebitacct,issuetype,linecost,linetype,transid,mrlinenum,mrnum,polinenum,ponum,porevisionnum,quantity,receivedunit,refwo,remark,requestedby,status,transdate,unitcost,receiptref,owner,invoicenum,tostoreloc,packingslipnum,issue FROM v_poreceipts 137 | 138 | UPDATE po 139 | SET po.ns_lastrecdate = 140 | isnull( (SELECT isnull(max(por.transdate),po.statusdate) 141 | FROM v_poreceipts por 142 | WHERE por.ponum = po.ponum 143 | AND por.receiptref is NULL 144 | AND por.issuetype = 'RECEIPT' 145 | GROUP by por.ponum) ,po.statusdate) 146 | WHERE po.receipts <> 'NONE' 147 | 148 | ''' -------------------------------------------------------------------------------- /samples/AS03_01_poreccomm.md: -------------------------------------------------------------------------------- 1 | # Automation script to create a custom action launch point 2 | 3 | ## Custom action launch point: PORECCOMM 4 | Called from Escalation PORECESC com.ibm.tivoli.maximo.script.ScriptAction 5 | PORECCOMM,PORECCOMM,PORECCOMM 6 | PO.LASTRECDATE is a custom attribute to reflect latest receipt date (MATREC or SERVREC) 7 | 8 | This sample script was written for Maximo Asset Management version 7.5.0.10. 9 | 10 | import java 11 | 12 | ```python 13 | 14 | from java.util import Calendar 15 | from java.util import Date 16 | from psdi.server import MXServer 17 | from psdi.mbo import MboConstants 18 | from psdi.mbo import MboSet 19 | from com.ibm.tivoli.maximo.util.mbo import IterableMboSet 20 | servDT = MXServer.getMXServer().getDate() 21 | df = java.text.SimpleDateFormat("MM/dd/yy kk:mm") 22 | dfnow = java.text.SimpleDateFormat("kk:mm:s:S") 23 | today = MXServer.getMXServer().getDate() 24 | now = dfnow.format(today) 25 | today = df.format(today) 26 | 27 | ``` 28 | 29 | ```python 30 | 31 | def log(e): print str(now) + ": "+str(launchPoint)+("__>> %s" % e) + "\r\n" 32 | print "*************" 33 | log("buffer") 34 | log("Entering Script:....."+str(now)) 35 | 36 | s_poNum = str(mbo.getString("PONUM") or None) 37 | s_poDesc = str(mbo.getString("DESCRIPTION") or None) 38 | s_poVend = str(mbo.getString("VENDOR.NAME") or None) 39 | s_poType = str(mbo.getString("POTYPE") or None) 40 | b_hasReceipts,b_sendComm = (False,)*2 41 | h_tableBody = "" 42 | d_lastRecDate = mbo.getDate("LASTRECDATE") or None # Custom attribute to display and reference on PO 43 | if(d_lastRecDate is None): d_lastRecDate = mbo.getDate("STATUSDATE") 44 | d_lastRec = d_lastRecDate 45 | d_newLastRec = d_lastRec 46 | 47 | ``` 48 | # Some substitution variables to use in HTML 49 | 50 | ```python 51 | 52 | h_left = " style=""text-align:left;""" 53 | h_size = " style=""font-size:90%;""" 54 | h_htmlHead = "" 55 | h_htmlFoot = "" 56 | h_tableBody = "" 57 | h_poHead = "

The following has been received from "+str(s_poVend)+" on PO:"+str(s_poNum)+"

"+str(s_poDesc)+"

" 58 | h_tableHead = "ItemDescriptionQuantity" 59 | h_tableFoot = "
" 60 | h_message = h_htmlHead 61 | ``` 62 | 63 | # Defining the sendComm function 64 | 65 | ```python 66 | 67 | def sendComm(s_templateId,s_subject,h_message): 68 | whereclause = "TEMPLATEID = '"+str(s_templateId)+"'" 69 | ctMboSet = mbo.getMboSet("$commtemp","COMMTEMPLATE",whereclause); 70 | ctMboSet.setQbeExactMatch("true") 71 | ctMboSet.reset() 72 | ctMbo = ctMboSet.getMbo(0) 73 | if(ctMbo is not None): 74 | ctMbo.setValue("SUBJECT",s_subject, MboConstants.NOACCESSCHECK | MboConstants.NOVALIDATION_AND_NOACTION) 75 | ctMbo.setValue("MESSAGE",h_message, MboConstants.NOACCESSCHECK | MboConstants.NOVALIDATION_AND_NOACTION) 76 | ctMbo.sendMessage(mbo,mbo); 77 | return 78 | 79 | s_matRecSql = " ponum = '"+s_poNum+"' and receiptref is NULL and issuetype = 'RECEIPT' and transdate > '"+str(d_lastRec)+"' " 80 | matRecSet = mbo.getMboSet("$MATREC$","MATRECTRANS",s_matRecSql) 81 | log("matRecSet.count(): "+str(matRecSet.count())) 82 | if(matRecSet.count() > 0): 83 | b_hasReceipts = True 84 | matRec = matRecSet.moveFirst() 85 | while(matRec is not None): 86 | d_mrTransDate = matRec.getDate("TRANSDATE") 87 | if(d_mrTransDate > d_newLastRec): d_newLastRec = d_mrTransDate 88 | s_toStoreLoc = matRec.getString("TOSTORELOC") or None 89 | if(s_toStoreLoc is None and s_poType == "STD"): 90 | s_itemNum = matRec.getString("ITEMNUM") or None 91 | s_itemDesc = (matRec.getString("DESCRIPTION") or None)[:65] 92 | s_itemQty = str(matRec.getFloat("QUANTITY")) 93 | b_sendComm = True 94 | h_tableBody = h_tableBody + ""+str(s_itemNum)+""+str(s_itemDesc)+""+str(s_itemQty)+"" 95 | matRec = matRecSet.moveNext() 96 | 97 | 98 | s_servRecSql = " ponum = '"+s_poNum+"' and receiptref is NULL and issuetype = 'RECEIPT' and transdate > '"+str(d_lastRec)+"' " 99 | servRecSet = mbo.getMboSet("$SERVREC$","SERVRECTRANS",s_servRecSql) 100 | log("servRecSet.count(): "+str(servRecSet.count())) 101 | if(servRecSet.count() > 0): 102 | b_hasReceipts = True 103 | servRec = servRecSet.moveFirst() 104 | while(servRec is not None): 105 | d_srTransDate = servRec.getDate("TRANSDATE") 106 | if(d_srTransDate > d_newLastRec): d_newLastRec = d_srTransDate 107 | if(s_poType == "STD"): 108 | b_sendComm = True 109 | s_servDesc = (servRec.getString("DESCRIPTION") or None)[:65] 110 | s_servQty = str(servRec.getFloat("QUANTITY")) 111 | h_tableBody = h_tableBody + "SERVICE"+str(s_servDesc)+""+str(s_servQty)+"" 112 | servRec = servRecSet.moveNext() 113 | 114 | 115 | log("*********") 116 | log("b_hasReceipts: "+str(b_hasReceipts)) 117 | log("b_sendComm: "+str(b_sendComm)) 118 | 119 | 120 | 121 | if(b_hasReceipts): 122 | log("Set PO.LASTRECDATE") 123 | mbo.setValue("LASTRECDATE",d_lastRec,MboConstants.NOACCESSCHECK | MboConstants.NOVALIDATION_AND_NOACTION) 124 | if(b_sendComm): 125 | log("Send Communication") 126 | s_templateId = "PORECEIPT" 127 | s_subject = "Receipts on PO: "+s_poNum+" "+str(df.format(d_lastRec)) 128 | # Build HTML for message 129 | h_message = h_message+h_tableHead+h_tableBody+h_htmlFoot 130 | sendComm(s_templateId,s_subject,h_message) 131 | 132 | log("Exiting Script") 133 | log("buffer") 134 | ``` 135 | 136 | ### SQL to prepare the environment to allow the automation scripting to work for this function 137 | 138 | ```sql 139 | 140 | V_PORECEIPTS 141 | create view dbo.v_poreceipts (siteid,orgid,itemnum,description,glcreditacct,gldebitacct,issuetype,linecost,linetype,transid,mrlinenum,mrnum,polinenum,ponum,porevisionnum,quantity,receivedunit,refwo,remark,requestedby,status,transdate,unitcost,receiptref,owner,invoicenum,tostoreloc,packingslipnum,issue) as 142 | 143 | (SELECT mr.siteid,mr.orgid,mr.itemnum,mr.description,mr.glcreditacct,mr.gldebitacct,mr.issuetype,mr.linecost,mr.linetype,mr.matrectransid 'transid', 144 | mr.mrlinenum,mr.mrnum,mr.polinenum,mr.ponum,mr.porevisionnum,mr.quantity,mr.receivedunit,mr.refwo, 145 | mr.remark,mr.requestedby,mr.status,mr.transdate,mr.unitcost,mr.receiptref,'MATRECTRANS',mr.invoicenum,mr.tostoreloc,mr.packingslipnum,mr.issue 146 | FROM matrectrans mr 147 | UNION ALL 148 | SELECT sr.siteid,sr.orgid,'Service',sr.description,sr.glcreditacct,sr.gldebitacct,sr.issuetype,sr.linecost,sr.linetype,sr.servrectransid 'transid',sr.mrlinenum, 149 | sr.mrnum,sr.polinenum,sr.ponum,sr.porevisionnum,sr.quantity,pol.orderunit,sr.refwo,sr.remark,pol.requestedby, 150 | sr.status,sr.transdate,sr.unitcost,sr.receiptref,'SERVRECTRANS',sr.invoicenum,NULL,NULL,1 151 | FROM servrectrans sr LEFT JOIN poline pol ON sr.ponum = pol.ponum AND sr.polinenum = pol.polinenum AND sr.porevisionnum = pol.revisionnum) 152 | 153 | V_MX_PORECEIPTS 154 | create view dbo.v_mx_poreceipts (siteid,orgid,itemnum,description,glcreditacct,gldebitacct,issuetype,linecost,linetype,transid,mrlinenum,mrnum,polinenum,ponum,porevisionnum,quantity,receivedunit,refwo,remark,requestedby,status,transdate,unitcost,receiptref,owner,invoicenum,tostoreloc,packingslipnum,issue) as 155 | SELECT siteid,orgid,itemnum,description,glcreditacct,gldebitacct,issuetype,linecost,linetype,transid,mrlinenum,mrnum,polinenum,ponum,porevisionnum,quantity,receivedunit,refwo,remark,requestedby,status,transdate,unitcost,receiptref,owner,invoicenum,tostoreloc,packingslipnum,issue FROM v_poreceipts 156 | 157 | UPDATE po 158 | SET po.ns_lastrecdate = 159 | isnull( (SELECT isnull(max(por.transdate),po.statusdate) 160 | FROM v_poreceipts por 161 | WHERE por.ponum = po.ponum 162 | AND por.receiptref is NULL 163 | AND por.issuetype = 'RECEIPT' 164 | GROUP by por.ponum) ,po.statusdate) 165 | WHERE po.receipts <> 'NONE' 166 | ``` 167 | -------------------------------------------------------------------------------- /samples/sample11/convert.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | SETLOCAL 4 | 5 | call commonEnv.bat 6 | 7 | set JAVA_HOME=..\..\java\jre 8 | 9 | rem Command line parameters are as follows 10 | rem -s represents source. Valid values are 11 | rem OS - Object Structure 12 | rem PH - Publish Channel 13 | rem ES - Enterprise Service 14 | rem IC - Invocation Channel 15 | rem WS - Web Service Registry 16 | rem EP - End Point 17 | rem EX - External System 18 | rem TABLE - Table 19 | rem BYOS - All objects for the Object Structure (have to have same where caluse) 20 | rem -n represents name (os name, es name, interaction name, table name ...). For multiple names use "," separation 21 | rem -x represents external system name (for es and ph). 22 | rem -w represents where clause (for table and byos). 23 | rem -f represents file name. Must end with .ora, .sqs, .db2, .sql, .dbc. For dbc scripts use .dbc 24 | rem -p represents the password - value must be the password to access the e-mail account 25 | rem -p represents the tenant code - value must be the tenant code for consultant users in MT 26 | rem -u represents the user - value must be a valid e-mail account name 27 | rem -h represents host name (if not used will use localhost) 28 | rem -a represents use header. Do you want to create sigoption header. If multiple interaction for one application. Header need to be created only once 29 | rem -r name of resource type when creating JSON resource (if specified resourcetype statemens will be created. Specify 0 if you do npot want to create resource type) 30 | rem -y add delete statement before insert 31 | rem -g for SIGOPTION grant application name 32 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sOS -nMXAPIASSET -y1 -fendpoint.dbc -umxintadm -pmxintadm -hlocalhost -t00 33 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sPH -nMXPOInterface,MXPRInterface -xEXTSYS1 -ftest.dbc -uwilson -pwilson -hlocalhost -t00 34 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sES -nIOTFASSET -xIOTFSYNC -fiotf.dbc -y1 -uwilson -pwilson -hlocalhost -t00 35 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sEX -nIOTFSYNC -fiotf.dbc -uwilson -y1 -pwilson -hlocalhost -t00 36 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sWS -nMXPO -ftest.dbc -uwilson -pwilson -hlocalhost 37 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sEP -nMXXMLFILE -ftest.dbc -uwilson -pwilson -hlocalhost 38 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sINT -nECRI -a0 -fecri1.dbc -uwilson -pwilson 39 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sTABLE -nAPPLICATIONAUTH -w"app='MXAPIWODETAIL' and optionname = 'INSERT'" -y1 -d1 -fauth.dbc -uwilson -pwilson -hlocalhost 40 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sTABLE -nIOTFCFG -w"1=1" -y1 -fyajin1.sql -uwilson -pwilson -hlocalhost 41 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sTABLE -nIOTFDEVICEMAPPING -w"1=1" -y1 -fyajin2.sql -uwilson -pwilson -hlocalhost 42 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sBYOS -nMXJSONMAPPING -w"mapname='WEATHERALERT'" -y1 -d0 -fmap.dbc -uwilson -pwilson -hlocalhost 43 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sBYOS -nMXOPERLOC -wsiteid='BEDFORD' -d0 -floc.sql -uwilson -pwilson -hlocalhost 44 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sJSONRES -nHISTORIAN -fhist.dbc -y1 -uwilson -pwilson 45 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sJSONMAP -nLAYER16IN -flayer16.dbc -y1 -uwilson -pwilson 46 | 47 | 48 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sTABLE -nASSETATTRIBUTE -w"assetattrid = 'MFGLIFE'" -y1 -d1 -fattr.dbc -uwilson -pwilson -hlocalhost 49 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sBYOS -nMXCLASSIFICATION -w"classstructureid = '157937'" -y1 -d1 -fspec.dbc -uwilson -pwilson -hlocalhost 50 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sTABLE -nMAXRELATIONSHIP -w"name in ('TEMPMETER', 'MFGLIFE')" -y1 -d1 -frel.dbc -uwilson -pwilson -hlocalhost 51 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sTABLE -nQUERY -w"clausename in ('Bad Actor - LTD Cost', 'METERSALARMLEVEL')" -y1 -d1 -fquery.dbc -uwilson -pwilson -hlocalhost 52 | 53 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sTABLE -nLOCATIONS -w"location like 'PUMPHOUSE%%'" -y1 -d1 -floc.dbc -uwilson -pwilson -hlocalhost 54 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sTABLE -nLOCATIONS -w"location like 'WELL FIELD%%'" -y1 -d1 -floc1.dbc -uwilson -pwilson -hlocalhost 55 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sTABLE -nLOCATIONS -w"location = 'TWC'" -y1 -d1 -floc2.dbc -uwilson -pwilson -hlocalhost 56 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sTABLE -nLOCOPER -w"location like 'PUMPHOUSE%%'" -y1 -d1 -flocoper.dbc -uwilson -pwilson -hlocalhost 57 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sTABLE -nLOCOPER -w"location like 'WELL FIELD%%'" -y1 -d1 -flocoper1.dbc -uwilson -pwilson -hlocalhost 58 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sTABLE -nLOCOPER -w"location = 'TWC'" -y1 -d1 -flocoper2.dbc -uwilson -pwilson -hlocalhost 59 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sTABLE -nMAXENDPOINTDTL -w"endpointname = 'IOTHISTCLOUD'" -y1 -d1 -fdet.dbc -uwilson -pwilson -hlocalhost 60 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sTABLE -nLOCHIERARCHY -w"systemid = 'WATER'" -y1 -d1 -flochier.dbc -uwilson -pwilson -hlocalhost 61 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sTABLE -nLOCSTATUS -w"location like 'PUMPHOUSE%%'" -y1 -d1 -flocstat.dbc -uwilson -pwilson -hlocalhost 62 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sTABLE -nLOCSTATUS -w"location like 'WELL FIELD%%'" -y1 -d1 -flocstat1.dbc -uwilson -pwilson -hlocalhost 63 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sTABLE -nLOCSTATUS -w"location = 'TWC'" -y1 -d1 -flocstat2.dbc -uwilson -pwilson -hlocalhost 64 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sTABLE -nLOCSYSTEM -w"systemid = 'WATER'" -y1 -d1 -flocsys.dbc -uwilson -pwilson -hlocalhost 65 | 66 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sTABLE -nASSET -w"assetnum like 'AH%%'" -y1 -d1 -fasset.dbc -uwilson -pwilson -hlocalhost 67 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sTABLE -nASSETSPEC -w"assetnum like 'AH%%'" -y1 -d1 -fassetspec.dbc -uwilson -pwilson -hlocalhost 68 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sTABLE -nASSETSPECHIST -w"assetnum like 'AH%%'" -y1 -d1 -fassethist.dbc -uwilson -pwilson -hlocalhost 69 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sTABLE -nASSETMETER -w"assetnum like 'AH%%'" -y1 -d1 -fassetmeter.dbc -uwilson -pwilson -hlocalhost 70 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sSTART -ftest.dbc -uwilson -pwilson -hlocalhost 71 | rem %JAVA_HOME%\bin\java -classpath ../classes;%MAXIMO_CLASSPATH%;.\mail.jar psdi.tools.DBCConverter -sEND -nALL -y1 -d1 -fsteve.dbc -uwilson -pwilson -hlocalhost 72 | -------------------------------------------------------------------------------- /samples/AS11_importExportScripts.md: -------------------------------------------------------------------------------- 1 | # Exporting and importing automation scripts by using a database configuration (dbc) file 2 | 3 | ## Introduction 4 | 5 | This document is a **Work in Progress** 6 | 7 | This document is not intended to be a substitute for the official Maximo API documentation. If any contradiction is present, you must consider the official documentation as the source of truth. 8 | 9 | You must have a basic knowledge about Maximo Asset Management and development, mainly Java, XML, and HTTP requests. You must be also familiar with Maximo applications and modules. 10 | 11 | This tutorial guides you through instructions to help you in export a sample automation script into a dbc file and them import it again by using the runscript.sh command line tool. 12 | 13 | ## Skill requirements 14 | 15 | * You **MUST HAVE** knowledge of Maximo instrumentation tools. 16 | * You **MUST HAVE** knowledge in how to work with command line instructions on Maximo Asset Management. 17 | * You **MUST KNOW** about the application server and Maximo deployment structure to easily localize the generated scripts by using the create.bat script file. 18 | * This document will be executed in MAC OS that uses a UNIX-based operating system. 19 | * You know how to use a terminal and how to handle the command prompt, particularly how to execute commands and navigates through directories on the file system. 20 | 21 | ## Software requirements 22 | 23 | * You **MUST HAVE** an instance of Maximo Asset Managenet version 7.5 or later. 24 | * You must know about the MAXIMO_HOME and MAXIMO_CLASSPATH variables. 25 | * You also know about the JAVA_HOME and CLASSPATH variables. 26 | 27 | ## For this sample 28 | 29 | You must have executed the [Schedule Dates](AS01_scheduleDates.md) sample in order to have a script to export and import. 30 | 31 | ## Import and export an automation script from a dbc file 32 | 33 | You can set up the environment to start using the tool to import or export an automation script into a dbc file. 34 | Recently, the latest version of Maximo Asset Management added the psdi.tools.DBCConverter tool, which includes the addition of some parameters that you can use to import and export an automation script to several different extensions. The following parameters are used to export the automation scripts: 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 |
-sSCRIPTThe source automation script.
-nThe name of the automation script.
-yAdd delete statement before insert.
-fThe file name. Must end with .ora, .sqs, .db2, .sql, or .dbc. For dbc scripts use .dbc
-hThe host name - if unspecified, localhost is used.
-uThe user in form of a valid e-mail account name.
-pThe password for the user.
-tThe tenant code - value must be the tenant code for consultant users in multi-tenancy.
46 | 47 | ## Tips for this documentation 48 | 49 | Use the following tips to improve your experience: 50 | 51 | ### Create a automation script by using the UI 52 | 53 | Complete the steps in [Schedule Dates](AS01_scheduleDates.md) to ensure that you have a script activated in Maximo Asset Management. 54 | 55 | ### Know your environment 56 | 57 | Locate the area on the server where the scripts are generated. 58 | 59 | For example, if you are following a standard installation for domains in the WebLogic Application Server, all the outputs from the converted script file are extracted into the following directory: 60 | 61 | ``` 62 | [WEBLOGIC_HOME]\user_projects\domains\[MAXIMO_DOMAIN]\[EXPORTED_SCRIPT] 63 | ``` 64 | 65 | Another folder that is named **script** will be created in this folder to store the exported scripts from Maximo Asset Management. 66 | 67 | ## Exporting an automation script into a dbc file 68 | 69 | ### Prerequisites 70 | 71 | * The steps in [Schedule Dates](AS01_scheduleDates.md) MUST BE executed. 72 | 73 | To check if the required sample was successfully executed, complete the following steps: 74 | 75 | 1. In the Maximo Asset Management Start Center, select **Go To > System Configuration > Platform Configuration > Automation Scripts**. 76 | 2. On the **List** tab, filter by script using the pattern COMPSETACTUALDATES or the given name for the executed sample. 77 | 78 | [Script](sample11/pic1.png) 79 | 80 | 81 | # Steps to export an automation script into a .dbc file 82 | 83 | 1. Open a command prompt or terminal. 84 | 2. Navigate to the following directory: /[MAXIMO_HOME]/tools/maximo/internal 85 | 3. Run the following command to extract the automation script in a dbc file: 86 | 87 | ``` 88 | $JAVA_HOME/bin/java -cp "../classes:$MAXIMO_CLASSPATH:mail.jar:/$MAXIMO_HOME/applications/maximo/lib/*:." psdi.tools.DBCConverter -sSCRIPT -n"COMPSETACTUALDATES" -y1 -fcompsetactualsdates.dbc -umaxadmin -pmaxadmin -hlocalhost -t01 89 | ``` 90 | 91 | **Note**: Depending on your environment, the slash representation and commands change whether you're using a UNIX-based operating system or a Windows-based operating system. 92 | 93 | The automation script COMPSETACTUALDATES is extracted into a .dbc file. The dbc file is available in the root folder of your WebLogic Server application domain. (i.e /WEBLOGIC_HOME/user_projects/domains/maximo) 94 | 95 | 96 | ## Importing a dbc file into the Automation Scripts application 97 | 98 | ### Prerequisites 99 | 100 | * For this example, you must delete the script that was generated from the [Schedule Dates](AS01_scheduleDates.md) sample by following these steps: 101 | 102 | 1. In the Maximo Asset Management Start Center, select **Go To > System Configuration > Platform Configuration > Automation Scripts**. 103 | 2. Filter the **Script** field to find the automation script COMPSETACTUALDATES. 104 | 3. Select the COMPSETACTUALDATES. 105 | 4. From the action menu, select **Delete Script**. 106 | 107 | [Delete Automation Script](sample11/pic2.jpg) 108 | 109 | 5. On the main tab of the Automation Scripts application, ensure that the COMPSETACTUALDATES script was deleted successfully. 110 | 111 | 112 | # Steps to import an automation script from a .dbc file 113 | 114 | 1. Open a command prompt window. 115 | 2. Use the following commands to navigate to the [MAXIMO_HOME]\tools\maximo\internal directory: 116 | ``` 117 | yourmachine-mbp:echo $MAXIMO_HOME 118 | /maximo 119 | yourmachine-mbp:~ user$ cd $MAXIMO_HOME 120 | yourmachine-mbp:maximo user$ cd tools/maximo/internal/ 121 | yourmachine-mbp:internal user$ 122 | ``` 123 | 3. In the internal folder, run the follow command at the command prompt: 124 | 125 | ``` 126 | yourmachine-mbp:internal usesr$ ./runscript.sh -c/[WEBLOGIC_HOME]/user_projects/domains/maximo/script -fcompsetactualsdates 127 | ``` 128 | 129 | The runscript.sh shell script has the following orientation from the usage prompt: 130 | 131 | ```kotlin 132 | Usage : -c -f