Field Validation Classes in Maximo

Hi,

In maximo there are three types of field validation classes which you can write depending on your circumstances:

1) Field validation class for a persistent field (normal field) in maximo

2) Field validation class for a persistent field (normal field) in maximo which needs to also have a lookup

3) Field validation class for a NON persistent field (normal field) in maximo

In this case lets consider the field we want to write a field validation class on is “LEADCRAFT” (some dummy name) and for scenario one its a persistent field.

Scenario 1) In this case we will write a java class which extends “psdi.mbo.MboValueAdapter” core maximo class. You will need to have a constructor of type below:

public FldValidationClass(MboValue mbv) {
super(mbv);

}

There are three important methods:

INIT: This method you can write code to setup the field whenever it is displayed on the UI

VALIDATE: This method will be called whenever this field is modified. So, like if someone types something from the frontend and tabs out this class is called. Even if someone in some other class sets value to “LEADCRAFT” field and does not set the flag to not call validation (MboConstants.NOVALIDATION), then also the field validation class is called.

ACTION: You should use this method if based on this field you want to set values on some other fields. One thing to note is ACTION is only called if VALIDATE is successful.

Scenario 2) In this scenario you want to write a field validation class on a field which also has a look up attached to it. If you specify DOMAINID and CLASSNAME both in MAXATTRIBUTE table, the custom class or field validation class is never invoked.

So, if you want a lookup as well as some custom validation and action. You should write a field validation class which extends psdi.mbo.MAXTableDomain.

Apart from the three methods listed above, the other important method in this scenario which become3s available is:

public MboSetRemote getList()
        throws MXException, RemoteException

You should override this method and return the MboSet with the values which will be displayed in the lookup.

Scenario 3) This scenario is mostly same as scenario No. 1 the only difference being, when you want to setup a non-persistent field to display on UI use the INITVALUE method instead of INIT in case of non-persistent fields.

Hope this helps, Enjoy!!

Regards,

Aniruddh Panvalkar

Advertisements

15 thoughts on “Field Validation Classes in Maximo

  1. Esther

    Hello,Thanks so much for your write up on feild validation.

    Am quite new on maximo and am presently using maximo 7.2.

    I want to make classification field mandatory while creating service request.

    I want a situation were if classification field is empty the service request form should not submit.

    Please Help.

    Thanks

    Reply
    1. admin Post author

      Hi,

      If you want to make that field required unconditionally then the best option is in screen design xml just put inputmode=”REQUIRED” it will make that field required.

      Field validation class can be used if you want that field to be mandatory in certain conditions.

      Regards,

      Reply
  2. Arun

    Thanks a lot for the write up. I would like to develop a custom condition class as well. My scenario is that: I have a table called ‘A’ and the table has fields ‘A1A’ to ‘A1N’, and these fields have a domain lookup where i can select the value from. So based on the value selected from the domain, i would like to hide or show another field say ‘X’ in the same table. By default ‘X’ is visible, and need to hide or make it invisible based on the domain value. Which scenario i have to use for this. NOTE: Why i am creating custom condition is because i have a strange problem with my maximo, conditional expression manager is missing, so i couldnt create any conditions. Other it would have been a simple task……Once again thanks for the amazing post

    Reply
    1. admin Post author

      Hi,

      I am not sure when you say conditional expression manager is missing. But, maybe you can add condition from backend using sql. If not, then the only option from java is to make the field readonly.

      You can write a simple field validation class which extends maxtabledomain. Override the action method in that check what domain value did the user select and based on that hide or show field X.

      Pesudo code:

      check domain val

      if(getmboValue() != null && getMboValue().getString().equalsIgnorecase(“something”)

      {
      getmboValue().getMbo().setFieldFlag(fieldname, MboConstants.READONLY)
      }

      Hope this helps

      Reply
  3. Matt

    I’m just a user that is frustrated at the Maximo programmers or script writer. I’m frustrated about a lot of things but the one thing I have going on right now is when entering in information from one specification tab to the next specification tab I’m waiting for validations I think? I have 30-40 rows of data to enter and they are never more than four characters long. I control arrow down but the system will not let me enter info till the system validates.

    Can you set this up so the validation doesn’t take place until you try to save the data from all 20-40 fields so the validation to the server only happens once? I want this to work like a good website that turns the errors or not valid fields red and flags the data that is not in line with the data set?

    Right now I have to wait and if I enter the wrong data it auto erases but allows the Ctrl+down arrow. I’m moving faster than the stupid system and going bonkers waiting for the system.

    I want the script writers to do a better job making this more user friendly but need some expertise.

    Thanks in advance

    Reply
    1. Matt

      ??The invalid data I entered would turn red but the good data stay black. The only way the data will save is if you correct the data that is now RED.

      Reply
    2. admin Post author

      Hi Matt,

      The validations happen at the field level as there are field level classes or domains/lookups associated with those fields.

      If you want validations to happen on save then you would have to remove those classes or if there is a domain you would have to configure it so that it won’t validate.

      The problem you might have is some bad values might slip through if you try to validate everything on save.

      Reply
  4. Salman

    I am new, i want to create a class for calculate outage of change application (calculate diff between start_time and finish_time)
    please help me now i am so frustrated.

    This is my custom class.

    package psdi.custom.system.beans;

    import java.rmi.RemoteException;
    import psdi.mbo.*;
    import psdi.util.MXApplicationException;
    import psdi.util.MXException;
    //import psdi.util.logging.MXLogger;
    //import psdi.util.logging.MXLoggerFactory;
    //import psdi.common.parse.ParseException;
    //import psdi.util.logging.FixedLoggerNames;

    public class custfield extends MboValueAdapter {

    /* custfield()
    {
    System.out.println(“———- Starting ———“);
    }
    */

    public custfield(MboValue mbo)
    throws MXException, MXApplicationException {
    super(mbo);
    }

    public void action() throws MXException, RemoteException {
    super.action();
    // MXLoggerFactory log = MXLoggerFactory.getLogger(APPLOGGER);

    try{
    //CommLogSet commLogSet = (CommLogSet) mxServer.getMboSet(“COMMLOG”, userInfo);

    long totalTime= getMboValue().getMbo().getDate(“ACTFINISH”).getTime() – getMboValue().getMbo().getDate(“ACTSTART”).getTime();
    long sec = (totalTime/1000)%60;
    long min = (totalTime/60/1000)%60;
    long hrs = (totalTime/60/60/1000)%24;

    getMboValue().getMbo().setValue(“STATUS”, “WAPPR”,11L);

    getMboValue().getMbo().setValue(“CUSTTOTALCHANGE”,hrs+”:”+min+”:”+sec);

    System.out.println(“———- RUNNING ———“);

    }
    catch (Exception e)
    {
    e.printStackTrace();
    System.out.println(“———- ERROR ———“);

    }
    }
    }

    Reply
    1. admin Post author

      I am sure you have found the answer by now but as I was not available for a few months could not reply to questions on the blog.

      If you just google how to calculate difference in date or time in java you will get your answer.

      Reply
  5. Sadequa

    Hi,

    I’m new to Mbo Customization, I read your blog its very helpful but as I said I’m new so I still do have some confusion.

    Well my requirement is to set one field value (checkbox true) depending on the value of other field.

    Supposing, I have 2 custom fields one is QTYCNTD (dummy field) and BALOK checkbox (dummy field) in Inventory table.
    Now, if user enters a value in QTYCNTD and tabout to enter next value, the system should take the value and compare this value with CURBAL field of inventory table, if CURBAL == QTYCNTD then the checkbox BALOK (present on the same application page) should get checked automatically. (note: BALOK is readonly by default.)

    Please tell me where should I put this fld validation class (on BALOK or QTYCNTD) and what method should I override (Action() or validate())

    Thanks

    Reply
  6. Amit

    Hi I want to achieve this in maximo 7.1 is it possible to do this without java customization?

    Thanks

    1.Provide validation on the re-order process to prevent ordering items where the status on the Inventory record is DO NOT ORDER, DO NOT RESERVE or DO NOT ISSUE.

    2.Provide validation on PR’s, PO’s and RFQ’s to prevent ordering items where the status on the Inventory record is DO NOT ORDER, DO NOT RESERVE or DO NOT ISSUE.
    3.Provide validation on Work Order Planned Materials to prevent reserving the Item where the status on the Inventory record is DO NOT RESERVE or DO NOT ISSUE.
    4.Provide validation on Inventory Issues to prevent Issuing an Item where the status on the Inventory record is DO NOT ISSUE.

    Reply
  7. Aparna SV

    My requirement is to hide a few work types in work order application and others as well. The field work type is associated with a field level class and not a domain.i tried to write the code in getList() just before returning super.getList(), but it is not working out:
    setListCriteria(LIST_CRITERIA_WHERE);

    Here , i have declared as : private static final String LIST_CRITERIA_WHERE = “worktype NOT IN (‘AA’,’BB’,’CC’,’DD’)”;

    Kindly let me know your idea.

    Reply
  8. Pingback: Field Class – Budding Learner

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s