Monday, 8 March 2021

Maximo Date Manipulation Using Automation Scripts

In this topic, we are going to see how to manipulate Maximo dates using Automation scripts. The different kinds of manipulation are

  1. Adding Number to the date
  2. Subtracting Number to the date
  3. Changing the format of the date
  4. Difference between two dates in days 

In the below examples we are going to use Python scripts in Maximo

  1. Object Launch Point is used
  2. Asset object
  3. The “INSTALLDATE” attribute is modified

  Java Calendar class is used for Date Manipulation.


1.     Adding Number to the date

Current date from MXServer is got and adding number (10) to that date.

print("**************Start of C_TEST ********************")
from java.util import Date
from java.util import Calendar
from psdi.server import MXServer

currentDate = MXServer.getMXServer().getDate()
cal = Calendar.getInstance()
cal.setTime(currentDate)

cal.add(Calendar.DATE, 10) 

print ("After Additional to Current Date ---> ",cal.getTime()) 

mbo.setValue("INSTALLDATE",cal.getTime()) 
print("**************End of C_TEST ********************")

Friday, 31 January 2020

Calling Automation Script from List Tab

There are times where we have a list of filtered value and we would like to perform some action on that filtered data. The best place to filter data is the List tab of the application. But when I have the filtered list, how can we call the logic to be performed on the data.

Step 1: Create an Action Automation Script.
Step 2: Make sure the action has been created
Step 3: Create a Signature Option with the same name as Action Name
Step 4: Make sure the "This is an action that must be invoked by user in the UI" option is checked in the Signature option
Step 5: Attach the signature option in the List tab.
Step 6: Make sure the mxevent and signature option are correctly mapped to button field.

Now the question comes where to attach the button group in the List tab


<table datasrc="results_showlist" id="results_showlist" inputmode="readonly" label="Work Orders" mboname="WORKORDER" selectmode="multiple">
<buttongroup id="1580274294655">
<pushbutton id="1580274294659" label="button 3" mxevent="C_WO" sigoption="C_WO" value="C_WO"/>
</buttongroup>
<tablebody displayrowsperpage="20" filterable="true" filterexpanded="true" id="results_showlist_tablebody">

Sample Action Automation Script.
print("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$")
print(mbo.getThisMboSet().count())
print("$%%%%%%%%%%%%%%#$@#$@#$@#$@#$@#$@#$@#$@#$@&%^&$%^&$%^&$^&$&")

The total number of work order that was filtered in the List tab was 30.


Log for the automation script is given in the below screen shot.



Now we have the mboset for work order. Using while or for we can loop through the mbo in action automation script.





Tuesday, 26 November 2019

Multiple Data Export for Single Page Application


When we have a single page application and we try to export the data, we are only able to export a single mboset value.

For Example:

Thursday, 24 October 2019

Result set is showing Current Date when the actual value is null


After Upgrading Maximo from 7.1 to 7.6.1.1 we had an issue with Maximo Result set, Empty Date fields are filled up with the current Date.
Below is the fix applied to resolve it.

Find resultsetportlet.jsp file

#WebSphere_Root/webclient/components/resultsetportlet.jsp

Search for "type==MXFormat.DATE" and change the if clause to below,

if ((type==MXFormat.DATE || type==MXFormat.DATETIME ) && finalData !=null && finalData.trim().length()>0)
Now you can see that Empty Date fields showing blank in Result Set

Tuesday, 13 August 2019

Populating Condition Codes By Just Clicking Condition Code Check Box in Maximo

Recently we had a requirement to add the condition Code on clicking the Condition Code Check box in Item application.

Below is the Code that was written in JavaScript,
Launch Point Type: Attribute Launch Point
Object: Item
Attribute Name: CONDITIONENABLED

importPackage(Packages.psdi.mbo);

var conditioncode  = mbo.getBoolean("CONDITIONENABLED");
var itemconditionSet = mbo.getMboSet("ITEMCONDITION");

if(conditioncode)
{
  for(i=0;i<3;i++)
  {
    var itemcondition = itemconditionSet.addAtEnd();
    if(i == 0)
    {
      itemcondition.setValue("CONDITIONCODE","A");
    }
    else if(i == 1)
    {
      itemcondition.setValue("CONDITIONCODE","B");
    }
    else if(i == 2)
    {
      itemcondition.setValue("CONDITIONCODE","C");
    }
  }
}



Friday, 9 August 2019

Signature Option Name to be displayed in Security Groups

In Maximo there is lot if Use for Sig options for hiding, making field required and many other purpose. But giving grant access in Security Groups is one of the toughest job. We create the sig option but we have to grant access to the sig option based on the description that was given in the application designer.

So to make things easy, we can also display the sig option name and the description together in Security Groups.

To make the sig option name to be displayed, navigate to the application designer application. Open the Security Groups (SECURGROUP) application.


Export the applicationid into a xml file. Find for the id appls_sigmain_table_tablebody_1a and appls_sigo_table_tablebody_1a. Include the the below tags

 <tablecol dataattribute="optionname" id="1565072808615"/> and 
 <tablecol dataattribute="optionname" id="1565072598311"/>

The final XML should look something like this,

Wednesday, 24 July 2019

Maximo Automation Script setting values while Initializing

There are times where we need to set the value when the object is invoked rather that setting the values during the save method. This can be achieved in Maximo automation scripts.

Step 1: Create an Object Launch Point with JavaScript.
Step 2: Make sure to check the Initialize? check box is checked. And all other check box are unchecked.
Step 3: Below is the sample code for setting the "Inspection Required" and "Adding Spare Parts" check box to always be checked when the item is created.

importPackage(Packages.psdi.mbo);
if(mbo.getString("ITEMSETID")=="ITEMSET1"){
    if(mbo.toBeAdded()==true){
        mbo.setValue("INSPECTIONREQUIRED", 1);
        mbo.setValue("SPAREPARTAUTOADD", 1);
    }
}