October 17, 2013

Implementing a Smart Search feature

Using Maximo search functionality can be sometimes complex or even frustrating.
Several customers have asked me if there is a simple Google-like functionality to search for all the objects that contains a specific set of words.
This article describes how to implement such feature in the Work Order Tracking application.

The solution described in this tutorial allows to display a simple search dialog when the user clicks on a specific button on the toolbar. When the user presses the 'Search' button the application will list the work orders containing all the keywords in any of the following fields: description, long description, location, asset, work logs.
Note that this is not achievable using the Advanced Search dialog since this will search with an AND logic instead of an OR logic implemented here.

In this screenshot you can see the custom search button and the very simple SmartSearch dialog.




The basic theory of how to create a custom dialog box to ask for user input is described in details in this article.


Create the custom Dialog Box

First of all we need to create the SmartSearch dialog box.
  1. Launch the Application Designer and open the WOTRACK application.
  2. Export the XML application definition to a local file.
  3. Open the exported file with a text editor.
  4. Scroll all the way down to the bottom of the file.
  5. Just before the </presentation> end tag, insert the XML code below.
  6. Save your changes.
  7. Go back to the Application Designer application.
  8. On the List tab, click on the Import Application Definition toolbar button to import your modified file.

Here is the dialog box definition.

<dialog beanclass="mxdev.webclient.beans.workorder.SmartSearchAppBean" id="ssearch" label="SmartSearch">
  <section border="false" id="ssearch_s1" mboname="smartsearch">
    <textbox dataattribute="searchtext" hidelabel="true" id="ssearch_s1_1"/>
    <blankline id="1381931693667"/>
  </section>
  <buttongroup id="ssearch_buttons_1">
    <pushbutton default="true" id="ssearch_btn1" label="Search" mxevent="search"/>
    <pushbutton id="ssearch_btn2" label="Cancel" mxevent="dialogcancel"/>
  </buttongroup>
</dialog>



Define the sigoption

Follow these steps to define the sigoption for the custom dialog box.
    1. Launch the Application Designer and open the WOTRACK application.
    2. On the Select Action menu, click on Add/Modify Signature Options.
    3. Click on New Row to add a new row:
      Option: SSEARCH
      Description: SmartSearch
    4. Exit out the Application Designer application.
    5. Launch the Security Groups application and open "EVERYONE" group.
    6. Go to the Applications tab.
    7. Search fo Work Order Tracking application and then for the 'SmartSearch' the new signature option. Grant access to it and save your changes.
    8. Done.


    Create toolbar button


    Follow these steps to create a custom toolbar button to launch your dialog box.
    1. Launch the Application Designer application.
    2. Retrieve the application which you modified on step 2.
    3. On the Select Action menu, click on Add/Modify Toolbar Menu.
    4. Click on New Row to add a new row. Use the following values:
      Element Type = OPTION
      Key Value = SSEARCH
      Position = 80
      Subposition = 0
      Image = find.gif
      Visible = Yes
      Tabs = LIST
    5. Click OK..
    6. Logout and login back.

    Checkpoint
    Launch the Work Order Tracking application and check that the new button and that by clicking on it the new SmartSearch dialog is displayed. Note that at this point you will still see an 'Invalid Binding' error.


    Create SMARTSEARCH object

    Follow these steps to create a non persistent object to support the application bean.
    • Launch Database Designer application.
    • Create an new object and enter the following information
      Object: SMARTSEARCH
      Description: Non persistent bean for SmartSearch
      Persistent: False
    • Save the record and go the the Attributes tab.
    • Create the following attribute:
      Attribute: SEARCHTEXT
      Title: Search text
      Type: ALN
      Length: 100
    • Save and apply database changes


    SmartSearch AppBean class

    Follow these steps to create and deploy the AppBean class.

    1. Download SmartSearchAppBean.java file.
    2. Open your development environment and copy SmartSearchAppBean.java into  mxdev.webclient.beans.workorder package.
    3. Compile and copy SmartSearchAppBean.class file in
      [SMPDIR]\applications\maximo\maximouiweb\webmodule\WEB-INF\classes\mxdev\webclient\beans\workorder
    4. Re-build and deploy Maximo EAR file.

    You can easily modify the set of fields in which the text is searched by modifying how the where clause string is built.


    References

    Custom Dialog Box tutorial (from Daniel NG)
    Call Java method on action menu or toolbar button click

    6 comments:

    1. Thanks Bruno. I have been following your blog ever since my involvement with our 6.2 to 7.5 Upgrade. Your examples have helped me tremendously. I have tried your example above and it works great. BTW I'd love to see a post on creating a simple custom application in Maximo using all custom mbo's.

      ReplyDelete
    2. Awesome Article,
      When I try to search I get this error

      BMXAA4210E - Database error number 8116 has occurred.
      Argument data type text is invalid for argument 1 of upper function.

      ReplyDelete
    3. Hi Bruno I have to do same thing but in Maximo 6.2.1 and I can't find any info on how do this for that version. I tried out copying your example but didn't work. Any suggest, comments or info where to get javadocs for 6.2.x version will be welcome.

      Thanks a lot for your time

      ReplyDelete
    4. Have you performance/load tested the smartsearch functionality if say it was implemented from the work orders module which can grow tremendously? What results did you get for a search on a large dataset?

      ReplyDelete