Archive for the ‘Maximo Tips’ Category

Restricting Status List on List tab

Hello;

You may want to restrict status list on some applications. For example in wotrack, on the list table you may want that the user can get status to ‘WAPPR’ . So other statuses like COMP,INPRG must be restricted from the list..

Here you should extend psdi.webclient.beans.workorder.WOChangeStatusBean class. And you must override public synchronized MboSetRemote getList(int nRow, String attribute) method. Here is how it can be done…

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 
package com.custom.workorder;
 
import java.rmi.RemoteException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import psdi.app.workorder.WORemote;
import psdi.mbo.*;
import psdi.security.UserInfo;
import psdi.server.MXServer;
import psdi.util.*;
import psdi.webclient.beans.common.ChangeStatusBean;
import psdi.webclient.system.beans.DataBean;
import psdi.webclient.system.beans.ResultsBean;
import psdi.webclient.system.controller.*;
 
public class newWOChangeStatusBean extends psdi.webclient.beans.workorder.WOChangeStatusBean
{
    public void initialize()
        throws MXException, RemoteException
    {
      super.initialize();
    }
    public synchronized MboSetRemote getList(int nRow, String attribute)
                throws MXException, RemoteException
            {
                        if(app.getApp().equalsIgnoreCase("WOTRACK") && app.onListTab()){
			MboSetRemote currentList=super.getList(nRow,attribute);
			currentList.setWhere("value in ('WAPPR') and domainid='WOSTATUS'");
			currentList.reset();
			return currentList;
			}
			else return super.getList(nRow,attribute);
             }
}

Here currentList is the list of statuses. We restrict it to show only WAPPR…
Now compile it rebuild, redeploy…
Now you have to tell maximo about new class. Go to the application designer..
From select action menu click export system xmls…
Click the arrow next to the LIBRARY.xml… New internet explorer window opens…
From File menu select “Save As”… Now take a back up of the original file in case of any accident…
Open it with a text editor like notepad++ …
Find the string with dialog id=”list_status” and replace psdi.webclient.beans.workorder.WOChangeStatusBean with com.custom.workorder.newWOChangeStatusBean

Import Library.xml to the system… Go to the application and test it…

Have a good day…

read comments here

Set Inbox Order

Hello;
Our clients always have problems with their inboxes. One of the major problem is that the inbox is not sorted. To sort inbox in Maximo we have to modify a jsp file. Here is how it is done.. This is done for Maximo 6.2.2
First we open %MAXIMOROOT%\applications\maximo\maximouiweb\webmodule\webclient\controls\startcenter\portlets\inbxconfig.jsp file. Take a backup of this file…

Then we should find

1
2
3
4
else
		{
			portletBean	= (InboxPortletBean)sessionContext.getCurrentApp().get(portletId);
		}

After these lines add these…

1
2
3
4
5
6
7
8
9
10
11
12
13
14
boolean allowsort = true;
		if (portletBean.isPropertyDefined("allowsort") && portletBean.getPortletInfoValue("allowsort") != null )
		{
		 if ( ((String)portletBean.getPortletInfoValue("allowsort")).equals("true"))
		 {
		  allowsort = false;
		 } 
		}
 
		if (allowsort)
		{
		 portletBean.setPortletInfoValue("sortattribute","startdate");
		 portletBean.setPortletInfoValue("sorttype","desc");
		}

On line 12,13 we ordered inbox to startdate descending… Then save the file… Rebuild and redeploy..

Have a good day…

PS: Test before taking it to the live system…

read comments here

Creating an Action Class

Hello;
Now I am going to tell about custom action classes…
These classes help us to add custom actions to workflows…
We must write these classes in the psdi.common.action package.. We extend ActionCustomClass and override applyCustomAction method to make maximo do what we want to do…

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package psdi.common.action;
 
import java.io.PrintStream;
import java.rmi.RemoteException;
import psdi.mbo.MboRemote;
import psdi.server.MXServer;
import psdi.util.MXApplicationYesNoCancelException;
import psdi.util.*;
import com.custom.workorder.*;
 
public class newFlowAction
    implements ActionCustomClass
{
 
            newFlowAction()
            {
            }
 
            public void applyCustomAction(MboRemote mboremote, Object aobj[])
                throws MXException, RemoteException
            {
 
              com.custom.workorder.newWORemote mbo=(com.custom.workorder.newWORemote)mboremote;
	       if(mbo.getString("STATUS").equalsIgnoreCase("INPRG")){
                        mbo.getMboSet("OTHEROBJECT").deleteAll();
                 }
            }
}

Here on line 23 we cast our mbo to custom Workorder object. Now we are able to use workorder’s methods on mbo object. On line 24 we check if the status is INPRG or not…
And on line 25 if the status is INPRG we select the OTHEROBJECT relationship and delete all mbo’s that came with OTHEROBJECT relationship…

Then we compile the code… Rebuild Maximo.ear.. Redeploy it… Now you can use it in the related workflow..

Have a good day…

read comments here

Writing a Custom Condition Class

One of the best improvements in Maximo 7.x is conditional user interfaces. You can create your conditions in Conditional Expression Manager application. But sometimes there are some issues that you can not write sql sentences. For these cases we can write our own condition class. We must extend psdi.common.condition.CustomCondition class to write the new class. And we need to override evaluateCondition(MboRemote mbo, Object arg1) method. Here is an basic example..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.custom.workorder;
 
import java.rmi.RemoteException;
import psdi.mbo.*;
import psdi.common.condition.CustomCondition;
import psdi.util.*;
 
public class TipCondition implements CustomCondition {
 
    public boolean evaluateCondition(MboRemote mbo, Object arg1) throws MXException, RemoteException {
        newWORemote wo = (newWORemote) mbo;
 if (wo.getString("ISSUETYPE").equalsIgnoreCase("PROBLEM")) {
            psdi.server.MXServer mxs = psdi.server.MXServer.getMXServer();
            MboSetRemote loc_set = mxs.getMboSet("LOCATIONS", wo.getUserInfo());
            loc_set.setWhere("location in('"+wo.getString("CENTER1")+"')");
            loc_set.reset();
            if (loc_set.count() > 0) {
                String kanal = loc_set.getMbo(0).getString("CAPACITY");
                if (kanal.startsWith("4")) {
                    return true;
                }
            }
            return false;
        } else {
            return false;
        }
    }
 
    public String toWhereClause(Object arg0, MboSetRemote arg1) throws MXException, RemoteException {
        return "";
    }
}

Have a good day…

read comments here

Import AlnDomain from Excel Sheet

Hello;

Now I will explain a bit about importing from excel sheet. Here I will use Jexcel Api to read excel files. This script was written for Maximo 6.2.1, and I will use Jexcel Api 2.6.9 which can be downloaded from here.
Here is the code:

/*
 * addAlnDomain.java
 *
 * Created on September 2, 2008, 4:00 PM
 */
import java.io.File;
import java.io.PrintStream;
import jxl.*;
import psdi.app.system.*;
import psdi.mbo.MboRemote;
import psdi.util.MXSession;
/**
 *
 * @author  bbolek
 */
public class addAlnDomain {
 
    /** Creates a new instance of addAlnDomain*/
    public addAlnDomain() {
    }
 
    public void add(String filename) {
        try {
            MXSession s;
            s = MXSession.getSession();
            s.setHost("localhost:9898/MXServer"); //Server Name
            s.setUserName("wilson");
            s.setPassword("wilson");
            s.connect();
 
            Workbook workbook = Workbook.getWorkbook(new File(filename + ".xls"));
            Sheet sheet = workbook.getSheet(0);
            int k = 1;
            String description, value;
                MaxDomainSetRemote maxdomain=(MaxDomainSetRemote) s.getMboSet("MAXDOMAIN");
                maxdomain.setWhere("DOMAINID='DOMAINNAME'");
                maxdomain.reset();
                MboRemote maxDomain=maxdomain.getMbo(0);
            while (sheet.getCell(0, k).getContents().length() > 1) {
                value = sheet.getCell(0, k).getContents().toString();
                description = sheet.getCell(1, k).getContents().toString();
                System.out.println("VALUE :"+value+ " DESCRIPTION: "+description );
 
                ALNValueSetRemote alnSet =(ALNValueSetRemote) maxDomain.getMboSet("ALNDOMAINVALUE");
                ALNValueRemote aln = null;
                aln = (ALNValueRemote) alnSet.addAtEnd();
                aln.setValue("VALUE", value);
                aln.setValue("DESCRIPTION", description);
	        alnSet.save();
                k++;
            }
        } catch (Exception E) {
            E.printStackTrace();
        }
}
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        addAlnDomain new_AlnDomain = new addAlnDomain();
        new_AlnDomain.add("Example");
    }
}

In here; between line 28-32 server settings are set. Then on line 34 excel workbook is opened.
On line 35 first sheet is selected. On line 39 the domain with name “DOMAINNAME” is selected.
Line 42 shows that the loop will continue if there is a value on the first column of excel.
Line 43 and 44 reads the excel and sets the variables. And on line 48 we create a new ALNDomain mbo. And on 49 we added it to the AlnDomainSet.
Then we bind the variables and save the MboSet…
On line 62 we set the excel filename…Here it is Example.xls

All Mbo’s can be read from excel and imported to Maximo in this way. It is quite easy and customizable…For example you can set some rules to import in java like
-import data that starts with 1,
-import data which is like ‘%10%’
-etc…

Have a good day…

read comments here

Creating a Field Class

Hello;

Another basic java functionality is to create a field class. Assume that you have a field. And if it is filled you have to make it readonly to prevent anyone changing the field. I’ll assume this field is WORKORDER.ASSETNUM… To do this we have to extend psdi.app.workorder.FldWOAssetnum class which is default class for this field. Here is the basic code..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package custom.workorder;
import psdi.mbo.*;
import psdi.util.*;
import psdi.app.workorder.FldWOAssetnum;
import java.util.*;
import java.rmi.*;
 
 
public class newFldWOAssetnum extends psdi.app.workorder.FldWOAssetnum
{
public newFldWOAssetnum (MboValue mbovalue) throws MXException, RemoteException
    {
        super(mbovalue);
    }
public void init() throws MXException {
        super.init();
        if(!getMboValue().isNull()) //If the value is not null
        {
            getMboValue().setReadOnly(true); //make it readonly
        }
    }
}

After this you have to write ‘custom.workorder.newFldWOAssetnum’ to the class field of WORKORDER.ASSET in database configuration.

Run configdb
Build maximo.ear
Redeploy maximo.ear

Have a good day…

read comments here

Database Export Utility

Hello;

There is a little known utility that helps us to export maximo database. This utility helps us to export database in any db type. For example assume that we are using oracle but we want to export database to use it in DB2. We can use this utility. It supplies us a maximo.db2 file which is like we use in maxinst.bat. You can find it in %MAXIMOROOT%\tools\maximo\internal\Unlcvt.bat

Here are the parameters that you can use with this tool:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Runs psdi.configure.Unlcvt.
The default name of the output file is Unlcvt.ora (Oracle), Unlcvt.sqs (SqlServer), or Unlcvt.ddl (DB2).
The default database is defined in the maximo.properties file.
The commandline parameters for overriding the defaults are listed below.
Also see javadocs for psdi.configure.Unlcvt.
-a (db alias)    Database alias. If not specified, uses mxe.db.url property.
-f (filename)    Filename for properties file.  If not specified, uses maximo.properties.
(Also see -k parameter for propfile directory.)
-k (propfile dir)    Directory for properties file.
(Also see -f parameter for propfile filename.)
-o (filename)    Filename of output file (without path or extension).
-p (password)    Password for database connection.
If not specified, uses mxe.db.password property, or "maximo".
-u (username)    Username for database connection.
If not specified, uses mxe.db.user property, or "maximo".
-x (db platform)    Output to a different db platform that the one being used for input.
(The default is to output to the same platform.)
Values for platform are: 1=Oracle, 2=SqlServer, 3=DB2.

Example Usage:

1
Unlcvt.bat -x3 

  exports database as db2 file….

Have a good day…

read comments here

Maximo Debug Window

Hello;

If you enter these to the address bar of your browser in any application of Maximo a new window appears which shows info about the client moves.. It is very useful for developers..

First enter..

javascript:eval(document.getElementById('debug_eventwindow').style.visibility='');

And Then

javascript:eval(document.getElementById('commframe').style.display='');

Then you will see a little window pop up on the left of the screen..

Have a good day…

read comments here