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…

4 Responses

  1. naci Says:

    thanks so bolek, but we want to code which is difficult. my mind is beautiful now. uhahaha.

  2. admin Says:

    Hello;
    This just explains the basics of field classes. Of course there can be more complex classes, but as everybody’s needs are different I can’t write it to here. If you have specific questions I can answer..

    Thanks…

  3. Henry Says:

    Hi Burak!

    I just learned about your site, and I am glad I did. This article answers a question that came up just the other day.

    One question however: Let’s suppose that on the work order tracking module I have a reported date and a started date. How would I enforce a rule that the started date could occur before the reported date?

    Many thanks again,

    /henry

  4. admin Says:

    Hello;

    You should use java customization to do that.. You can use something like this:

    1
    2
    
    if(getMboValue("STARTEDDATE").getDate().after(getMboValue("REPORTEDDATE").getDate()))
    				throw new MXApplicationWarningException("wotrack","startafterreprtdate");

    Have a good day…

Leave a Reply