Sabtu, 16 Agustus 2014

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


      Source:http://maximodev.blogspot.com/2013/10/maximo-smart-search.html

      Tidak ada komentar:

      Posting Komentar