Multiple Select in Maximo

An updated version at below

https://www.maximomize.com/multiple-select-in-maximo

Selecting single select items in maximo is piece of cake but configuring multiple select takes some customization to be implemented.

In this tutorial I will guide in creating Multiple select in Maximo.

Requirement

I had a requirement to enable Multi-select in a lookup. The user should be able to select Multiple options from the list. All the selected option should be entered in a list as a comma separated list in a single text box.

Implementation

  1. Add values in Libraries
    For our this custom multi select menu we need to add some code in Library and Lookup.
    Go to Application designer click on Select Action drop down. There select export System XML.CropperCapture[131]This will open the following dialog.
    CropperCapture[132]
    In the dialog click the arrow against lookups and library. This will download lookups.xml and library.xml

    a. Lookup.xml
    We need to create a custom lookup for our requirement.  For this open lookups.xml
    Insert in the bottom of the file the following lines

    
    <table id="multicustomlookup" inputmode="readonly" selectmode="multiple">
     <tablebody displayrowsperpage="20" filterable="true" filterexpanded="true" id="multicustomlookup_">
     <tablecol dataattribute="value" id="multicustomlookup_value_multiple" labelcss="txtbold txtitalic" mxevent="selectrecord" mxevent_desc="Go To %1" sortable="true"/>
     <tablecol dataattribute="description" id="multicustomlookup_desc_multiple" sortable="true"/>
     </tablebody>
     </table>]

    Save the file

    b. Library.xml
    Open Library.xml. In this file search for this code snippet

     <dialog beanclass="psdi.webclient.system.beans.LookupBean" icon="img_lookup.gif" id="query_lookup" label="Select Value"> <lookup id="querylookupcontrol"/> <buttongroup id="querylookup_3"> <pushbutton default="true" id="querylookup_3_1" label="OK" mxevent="dialogok"/> <pushbutton id="querylookup_3_2" label="Cancel" mxevent="dialogcancel"/> </buttongroup> </dialog>

    Replace it with the following code.
    [code language="xml"] <dialog beanclass="yourpackage.MLMultiSelect" icon="img_lookup.gif" id="query_lookup" label="Select Value">
    <lookup id="querylookupcontrol"/>
    <buttongroup id="querylookup_3">
    <pushbutton default="true" id="querylookup_3_1" label="OK" mxevent="dialogok"/>
    <pushbutton id="querylookup_3_2" label="Cancel" mxevent="dialogcancel"/>
    </buttongroup>
    </dialog><dialo 
    [/code]
    Save the file and import both files (lookups.xml and library.xml) back in to maximo by using the import application definition in Maximo.

  2. Application DesignerIn application designer open the application you need to edit.
    Select the attribute you want to edit. Right click – Properties.
    In the lookup field insert “multicustomlookup” without quotes. Save the application.
    CropperCapture[134]
  3. Java Code
    Create a new class file. Past the the following code in it.

    /**
     * Created by Rana Ahmed on 4/25/2016.
     * For Multi Selection in Domains
     */
    
    import psdi.mbo.MboConstants;
    import psdi.mbo.MboRemote;
    import psdi.util.MXException;
    import psdi.webclient.system.beans.LookupBean;
    import psdi.webclient.system.controller.Utility;
    
    import java.rmi.RemoteException;
    import java.util.Iterator;
    import java.util.Vector;
    
    public class MLMultiSelectTest extends LookupBean {
        private static String comma = ", ";
    
        public void initialize() throws MXException, RemoteException {
            /* This is called to select the values when the dialog is initialized. It will loop through the comma seperated values and select them in the dialog.*/
            super.initialize();
            String fieldToSet = getParent().getReturnAttribute();
            MboRemote mbo = this.app.getDataBean().getMbo();
            String value = mbo.getString(fieldToSet);
            String values[] = value.trim().split("\\s*,\\s*");
            for (int i = 0; i < values.length; i++) {
                for (int j = 0; j < getMboSet().count(); j++) {
                    if (values[i].trim().equalsIgnoreCase(getMboSet().getMbo(j).getString("value").trim())) {
                        getMboSet().select(j);
                    }
                }
            }
    
        }
    
        public int execute() throws MXException, RemoteException {
            /*This selects the iterates the values and inserts them as a comma seperated list */
            boolean onListTab = this.app.onListTab();
            if (onListTab)
                return super.execute();
    
            String commaString = new String();
            String fieldToSet = getParent().getReturnAttribute();
    
            Vector<?> selectedRecords = getMboSet().getSelection();
            Iterator<?> selectionIterator = selectedRecords.iterator();
            while (selectionIterator.hasNext()) {
                MboRemote currentSelectedValue = (MboRemote) selectionIterator.next();
    
                if (commaString.length() == 0)
                    commaString = currentSelectedValue.getString("VALUE");
                else
                    commaString += comma + currentSelectedValue.getString("VALUE");
            }
    
    
            //custom for Specific Fields
            //Use it if you want to process some custom rules.e.g. If a user selects a specific value, he cannot select any other value with it.
            //In my requirement if the user selects "Not Applicable" then he should not select any other value with it.
            if (fieldToSet.equalsIgnoreCase("MYCUSTOMFIELD") && commaString.contains("Not Applicable")) {
                if (!commaString.equalsIgnoreCase("Not Applicable")) {
                    String parms[] = new String[1];
                    parms[0] = "ABC";
                    Utility.showMessageBox(sessionContext.getCurrentEvent(), "myapp", "notapplicable", parms);
                    return 0;
                }
            }
    
            //End Custom Specific Rules
    
            MboRemote mbo = this.app.getDataBean().getMbo();
            mbo.setValue(fieldToSet, commaString, MboConstants.NOVALIDATION);
            app.getAppBean().refreshTable();
            return 1;
        }
    
    }
    
    

4. Deploy the code and restart Maximo
5. Check
Open you application and try selecting some multi select values. It should now paste them as comma seperated list.
CropperCapture[136]
Click again on lookup icon and it should display those comma separated values as selected values.
CropperCapture[137]

Thanks to this blog for much help

17 thoughts on “Multiple Select in Maximo

  1. Thanks Mike. I’ll have a look and will add it to article if it works

    Like

  2. You can replace main object to child (getParent()) if you use lookup in child table, in writeback section.

    //MboRemote mbo = this.app.getDataBean().getMbo();
    MboRemote mbo = getParent().getMbo();
    mbo.setValue(fieldToSet, commaString, MboConstants.NOVALIDATION);
    app.getAppBean().refreshTable();
    return 1;

    Liked by 1 person

    1. refreshTable need to changed for child table/ too

      //app.getAppBean().refreshTable();
      getParent().refreshTable();

      Liked by 1 person

  3. any chances to do it Automation script

    Like

    1. As far as I know .. Its not possible in automation scripts.

      Like

  4. Hi Rana,
    If i replace the existing dialog box in library.xml the lookups in list tab for multi select are not working.
    Thanks

    Like

    1. Which of the dialogs did u update?

      Like

  5. Sankar Ganesh V S September 27, 2019 — 3:00 pm

    Hi, Will this affect the Multi select Lookups in Report Request Pages.? Since you have used ‘if (onListTab)’ in execute() method, You could also use getMboSet().getApp()==”AppName” to restrict to particular application.

    Thanks!

    Like

    1. It should not interfere with report multi select.
      I am already restricting based on getApp and other conditions in our production. This is just meant to be a basic tutorial

      Like

  6. Hi Rana.. can i use the same code to configure lookups on a custom dialog? will it work?

    Like

    1. It’s multiple select functionalitues should on attributes and their lookups in dialogs as well. Let me know if you face any issue

      Like

  7. I tried this solution on Maximo version 7.6.0.1 , its working, but problem is then on other lookups which have table domain on attributte, when I click on icon for search dialog wont open to select values then. Any suggestions?

    Like

  8. Whats the lookup value you set on the attribute you want multiselect to work on?

    Like

    1. I set lookup value ALNVALUE, I must to explain more in details, for example on applications like Work order tracking on a list we have lookup and when I click https://imgur.com/a/QgWIHEr same problem I have at other applications only on a list like here.

      Like

      1. 1. The attribute with the lookup of ALNVALUE works fine? Is ALNVALUE a built in lookup or you created a new one

        2.The attributes whose are having issues their lookup is multiselect too?

        3. Re check if you have replaced the correct library class file

        4. You can disable your code on initialization when lookup dialog is launched. By checking if on list tab. The same way its doing on execute. e. g. if (onListTab) {
        super.initialize();
        return;
        }

        Like

  9. Hi Rana,

    Thank you so much for sharing an excellent solution to enable the multiple-select concept in Maximo. I was able to utilize your idea and implement the solution, but the challenge we are having is with integration. When we get the values back from integration with comma-separated values for these multi-select fields. Maximo is validating it against the domain, failing because of the multiple values. Any idea how to overcome this issue for integration.

    Like

    1. Try using integration classes or jython while the incoming packet is being processed to set the value forcefully

      Like

Leave a reply to mick Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.