Friday, 22 November 2019

Auto Refresh Start Center | Maximo

 A small javascript snippet we will embed in the startcenter-options.jsp file to reload the page based on the interval. 


path: maximo.EAR\maximouiweb\webmodule\webclient\components\startcenter-options.jsp

just copy the below code and paste before the <table> tag in startcenter-options.jsp file:

<script type="text/javascript">

  setTimeout("location.reload(true)", 60000);

</script>


Saturday, 9 November 2019

Dynamically modifiy the body of Communication Template Jython | IBM Maximo

Recently we have a requirement to modify the content of communication templates based on the record; for instance, put all the lines of a PO into the communication template before sending an email.

Also, this technique can be used to send PO to the vendor by creating a new relationship to get the email id of the vendor from Companies.

1. Create an Object Launch Point automation script with SAVE - ADD - After Save events.
2. put this code as a script. it will call an existing template, modify and send it.

 
if (mbo.getString("STATUS") == "APPR"):
      # whereclause is a string with condition to select a comm.template
      whereclause = "TEMPLATEID ='PO-APPR-MGRR'"

      # Get the Communication template via Asset relationship to send email 
      # mbo is implicit asset object through which we get a template            
      ctMboSet = mbo.getMboSet("$commtemp","COMMTEMPLATE",whereclause);
      ctMboSet.setQbeExactMatch("true")
      ctMboSet.reset()
      ctMbo = ctMboSet.getMbo(0)
     
      corcount = mbo.getMboSet("POLINE").count()
      coractionset = mbo.getMboSet("POLINE")
      txtres = " "
         

Thursday, 12 September 2019

Top N rows in a group by using row_number function | SQL

Let say I have this below data in my table for instance:



and my desired output is as below: Group it by WONUM but also I want to see the 2 records of each group.


Sunday, 8 September 2019

Create a Custom Dialog and Save Values in Custom Object | IBM Maximo

 A requirement is to have a custom dialog box which will be called by Select Action or from workflow during status change for instance:

Below is the simplest workaround by creating a non-persisten attribute in primary object and use it in dialog then run your automation on it and do your logic to store/insert.

Step by step is as beLow:

1. add non persistent attribute in pr ojbect (NP_STATUSMEMO)
2. pr to pojust relationship: ownerid = :prnum and object='PR'
3. add signature: MYDIALOG and grant to maxeveryone
4. add actio menu and attach signature MYDIALOG as option
5. DIALOG IN pr.xml attached below, add required fields to display
6. write ALP for this attribute validate with below jython


Sunday, 18 August 2019

Playing with Dates in Jython Automation Script | IBM Maximo


SimpleDateFormat - String
from java.util import Date
from java.text import SimpleDateFormat

vCurrentDate = SimpleDateFormat("MM/dd/yyyy").format(Date())
vReportDate = SimpleDateFormat("MM/dd/yyyy").format(mbo.getDate("reportdate"))
if vReportDate > '08/18/2019' or vReportDate > vCurrentDate  :
    mbo.setValue("DESCRIPTION",str(vReportDate))


Date Utility - Get Current Date Only (00:00 midnight) 

https://developer.ibm.com/static/site-id/155/maximodev/7609/maximocore/businessobjects/psdi/app/common/DateUtility.html

from java.util import Date
from psdi.app.common import DateUtility

today = DateUtility.getDate(Date())

yesterday = DateUtility.addDays(today, -1)

AddDays = DateUtility.addDays(today, 5)

AddMinutes = DateUtility.addMinutes(today, 2)


 

Thursday, 16 May 2019

Run Report Action if missing in a Custom Application | Maximo

1. Open your application in application designer, i.e. XXPR 

2. Select Action > Add/Modify Signature Options -> New Row(B)

Option: RUNREPORTS

Description: Run Reports

Visible? Yes

OK.

3. Select Action > Add/Modify Select Action Menu > New Row(B)

Element Type: OPTION
Key Value: RUNREPORTS
Position: 20
Subposition: 0
Visible? Yes

4. Grant Access to this Signature from Security Group.

you are done :) 

Tuesday, 14 May 2019

Limit ALN Domain Values based on Complex Business Logic | Maximo

1. Create Custom Condition Launch Point Automation Script
mrline = mbo.getMboSet("MRLINE")
if mrline is not None:
 evalresult = False

2. Create New condition expression:
Type: Class
Class: com.ibm.tivoli.maximo.script.ScriptCustomCondition
Expression: MyScriptName:MyLaunchPoint
3. Attach this condition to any of your ALN domain value.

Automation Scripts within Conditional Expressions to control business logic | Maximo

We are very well aware of these Attribute Launch Point, Object Launch Point, Action Launch Point but today we are going to discuss Custom Condition Launch Point.

Sometimes complex business logic involving conditions that need to be evaluated and cannot be covered in simple conditional expression, therefore we need to evaluate conditions within automation script to take the result into conditional expression.

Its a simple 3 steps process:
1. An automation script to handle all business logic
2. Conditional Expression to have this automation in it.
3. use this conditional expression wherever you want.

1. for instance:
lets create a Custom Condition Launch Point ISWONEW
script name is CHECKIFWONEW
Object: WORKORDER
Launchpoint Type: CUSTOMCONDITION
script:
evalresult = onadd
# evalresult = False or True
evalresult is an implicit variable in Custom Conditional Launch Point

2. Conditional Expression; create new
Name: ISWONEW , name as created a launchpoint in step 1
Expression: CHECKIFWONEW:ISWONEW (scriptname:launchpoint)
Class: com.ibm.tivoli.maximo.script.ScriptCustomCondition


reference: https://expertinmaximo.wordpress.com/2016/08/26/automation-script-for-conditional-expressions/

Wednesday, 24 April 2019

Loops in Automation Script | Maximo

#looping
--for loop
LineSet = mbo.getMboSet("INVUSELINE")
for i in range ( 0, LineSet.count() ):
line = LineSet.getMbo(i)
.... code here

--while loop-------------
LineSet = mbo.getMboSet("INVUSELINE")
line = LineSet.moveFirst()
while (line):
...code here
line = LineSet.moveNext()

----
assetSet = mbo.getMboSet("Asset")
asset = assetSet.moveFirst()
while(asset):
....code here
asset = assetSet.moveNext()

Monday, 22 April 2019

Limit SR Classification based on other attributes

1. Copy classfication diaglog from Library.xml and paste it into presentation (sr.xml) file.
<dialog id="associateClassification" label="Classify">
        <tree beanclass="psdi.webclient.beans.assetcat.AssociateSpecBean" allowqualifiedrestriction="true" height="250" id="associateClassification_tree" maxchildren="1000" relationship="CLASSSTRUCTURESR"  openfirstlevel="false" width="600">
            <treenode displaykeyattribute="false" displayobjectname="false" id="associateClassification_tree_node1" keyattribute="classstructureuid" objectname="CLASSSTRUCTURE">
                <treeattribute dataattribute="classificationid" display="true" id="associateClassification_tree_node1_attr1"/>
                <treeattribute dataattribute="classificationdesc" display="true" id="associateClassification_tree_node1_attr2"/>
            </treenode>
        </tree>
        <buttongroup id="associateClassification_2">
            <pushbutton default="true" id="associateClassification_2_2" label="Cancel" mxevent="dialogcancel"/>
        </buttongroup>
</dialog>
2. create a new relation in SR Object for Classstructure as child object

commoditygroup=:commoditygroup and contract=:contract

3. import sr.xml again and good to go.


Thanks to Haris who did it atlast.


Tuesday, 16 April 2019

Create new Crontask based on Automation Script | Maximo



Step 1. Create a Script with any Name, as in my Example my Script Name is CRONAUTOMATIONSCRIPT


from psdi.server import MXServer
from psdi.util.logging import MXLoggerFactory

log = MXLoggerFactory.getLogger("maximo.script.aqautoscript")

mxserver = MXServer.getMXServer()
userInfo = mxserver.getSystemUserInfo()

 # arg = crontask scriptarg parameter 
if instanceName and scriptName and  arg:
    AssetSet = mxserver.getMboSet("ASSET", mxserver.getSystemUserInfo())
    AssetSet.setWhere("ASSETNUM = '" + arg + "' ")
    AssetSet.reset()
    asset = AssetSet.getMbo(0)
    if asset:
        asset.setValue("description",arg)
    AssetSet.save()
    
log.info('\n instanceName is: ' + instanceName )
log.info('\n ARG is: ' + arg)
log.info('\n Automation Script name: ' + scriptName)

Monday, 8 April 2019

Set Multiple fields readonly

from psdi.mbo import MboConstants
fields = ['DESCRIPTION','ITEMTYPE', 'ORDERUNIT']
itemMbo.setFieldFlag(fields, MboConstants.READONLY,False)

Populate GL attribute in All Lines at ONCE from Header | IBM Maximo

Update all lines in Inventory Usage application from header level.

for instance in this example we are using a GL Debit account field on header level, and when we enter values in it; it will be copied into all lines.

To do this we will run a simple automation script using jython:

Attribute Launch Point:

Script: GLDEBIT_INVUSAGE
Langauge: jython

Launch Point:
Object: INVUSE
Attribute: CUXGLDEBIT
Event: Validate

Script Code:
lineSet= mbo.getMboSet('INVUSELINE')
line= lineSet.moveFirst()
while (line):
    line.setValue("GLDEBITACCT",mbo.getString("CUXGLDEBIT"))
    line = lineSet.moveNext()

Monday, 1 April 2019

Add Default Value to Lookup for Filtering | IBM Maximo



Export Lookup.xml

find lookup table tag and just paste default value tag into it, see below example:

    <table id="laborcraftrate" inputmode="readonly" selectmode="single">
        <tablebody displayrowsperpage="20" filterable="true" filterexpanded="true" id="laborcraftrate_lookup_tablebody">
            <tablecol dataattribute="orgid" id="laborcraftrate_lookup_tablebody_col_1" mxevent="selectrecord" mxevent_desc="Go To %1" sortable="true" type="link"/>
            <defaultvalue dataattribute="contractnum" defaulttype="query" id="laborcraftrate_lookup_tablebody_default" value="BEDFORD"/>
        </tablebody>
    </table>
import lookup.xml again.

we are done :)

Saturday, 30 March 2019

Hide a Button in Maximo Using Signature Options with Conditions | IBM Maximo



In this example we are going make a "NEW ROW" Button of Tasks in Plan Tab of Workorder application
1.       Add/Modify a new Signature Options HIDENEWROW from application designer’s Action Menu

2.       In Properties of Button, Set Signature Option: HIDENEWROW, newly created in step 2
3.       In properties of button under signature option, set Sig Option Data Source ID: MAINRECORD
4.       In security Group grant and attach your condition (Make a condition e.g. hide when Reported by Mr. WILSON (:Reportedby = ‘WILSON’) or 1=0)

5.       Sign-out and Login again, you are done! J