September 19, 2011

Application default search filters

I know that there is an official IBM Technote that already provides a solution to apply a default filter in a given Maximo application.
However this solution has some drawbacks. The main problem I see is that using this technique the field filters are not displayed in the application so it could be tricky for the user to understand what's happening.

I have found a better solution customizing the application's Java bean class (AppBean) specifying the QBE (Query By Example) parameters to the application DataBean in the initializeApp() method.
Here is a practical example about how to do this on the WOTRACK application.

To determine which Java bean handles the application, open Application Designer and select the application, from the Action menu choose 'Toggle Show All Controls' and display the properties of the 'presentation' section. The 'App Bean Class' defines the Java class that you need to customize. For the WOTRACK application it should be psdi.webclient.beans.workorder.WorkorderAppBean.
You should extend this class and override the initializeApp() method adding your filters as QBEs to the application's DataBean.
Here is how the custom class should look like.

public class CustomWorkorderAppBean extends WorkorderAppBean
{
  public void initializeApp() throws MXException, RemoteException
  {
    DataBean resultsBean = this.app.getResultsBean();
    resultsBean.setQbe("siteid", "XXX");
    resultsBean.setQbe("someotherfield", "1234");
    super.initializeApp();
  }
}

Put the custom AppBean class file in the Maximo tree, rebuild and redeploy the EAR file. Don't forget to change the App Bean Class property setting your own custom class.

7 comments:

  1. Hi Bruno

    I have an application Bean that extend DataBean.
    the problem is that I want to edit in the query to select from another DB object as an example("if the data retrieved from Inventory table, I want to edit the query to get the data from Invbalces table"). How can I make this?

    Thanks for advanced

    ReplyDelete
  2. Hi Bruno,

    I tried to implement the solution that you have demonstrated above but facing some issue. My intention is to set the default value of worktype field as "PM" in the advance search screen of WOTRACK application. My final code is mentioned below:
    ***************************************************************************
    package psdi.custom.webclient.beans.workorder;
    import java.rmi.RemoteException;
    import psdi.util.*;
    import psdi.webclient.beans.workorder.WorkorderAppBean;
    import psdi.webclient.system.beans.DataBean;

    public class CustomWorkorderAppBean extends WorkorderAppBean{

    public CustomWorkorderAppBean()
    {
    }
    public void initializeApp() throws MXException, RemoteException
    {
    DataBean resultsBean = this.app.getResultsBean();
    resultsBean.setQbe("worktype", "PM");
    resultsBean.reset();
    super.initializeApp();
    }
    }

    *********************************************************************
    In the Presentation Properties of WOTRACK application I set the App Bean Class as my custom class which is "psdi.custom.webclient.beans.workorder.CustomWorkorderAppBean" and then I build and deploy after putting this class file in the maximo class hierarchy which is "SMP\maximo\applications\maximo\maximouiweb\webmodule\WEB-INF\classes\psdi\custom\webclient\beans\workorder".

    But when I go to the work order screen I get some strange XML tags as mentioned below and the work order application doesn't load properly:
    ************************************************************************
    Quick Insert




    var el = document.getElementById("mx150"); if(el) { el.style.display=""; } ]]>
    Security, Users and Groups




    var el = document.getElementById("mx162"); if(el) { el.style.display=""; } ]]>
    Workflow Configuration




    var el = document.getElementById("mx180"); if(el) { el.style.display=""; } ]]> var el = document.getElementById("mx191"); if(el) { el.style.display=""; } ]]> var el = document.getElementById("mx211"); if(el) { el.style.display=""; } ]]>
    ***********************************************************************************



    Am I missing something or I need to do some other additional steps? Pls advise.

    Thanks in advance.

    ReplyDelete
    Replies
    1. These weird messages in the application are typically caused by failures in the class loading.
      If you check the system logs and you will probably find a ClassCast or a ClassNotFound exception.

      Delete
  3. Thanks Bruno, but my custom class file as mentioned in the presentation XML "psdi.custom.webclient.beans.workorder.CustomWorkorderAppBean" is actually present in the "maximo\applications\maximo\maximouiweb\webmodule\WEB-INF\classes\psdi\custom\webclient\beans\workorder" folder structure. Any idea as if why class could not be found?
    I appreciate your help.

    ReplyDelete
  4. Hi Bruno,

    How do i introduce a filter option in the web service section while i create a new web service to filter out the option to search for a specific enterprise service/object structure.

    Thanks.

    ReplyDelete
  5. Hi guys, there is one more way that allows you to put default filtering an any table, which will be visible to users, and do not require customizations. Per app, designer guide:
    You can use the Application Designer to define a default query for a table
    window using the Default Value control. When you first open the table, the
    system uses the query value or values you define to filter the records displayed
    from a table. For example, if you query the attribute ITEM_DESCRIPTION and specify
    a value of MOTOR, then the table only displays item records that have MOTOR
    somewhere in the description. You can also use % as a wildcard and = for exact
    match. If you set the value to =MOTOR, the system displays item records with only
    MOTOR in the item description.
    To define a default filter for a table:
    1 In the Application Designer, open an application in the Workspace tab.
    2 Drag the Default Value control into the section that contains the table for
    which you want to define a default filter.
    If you do not see the Default Value control in the section, click Select Action >
    Toggle Show All Controls.
    3 Open Control Properties for the control, and enter the following information:
    - The name of the attribute of the column to which you are assigning the
    default query
    - The desired value in the Value field (use a comma as a delimiter if you
    filter based on multiple values)
    - Select Query for4 Default Type

    ReplyDelete