↓ Skip to main content
An ink and watercolour drawing of a kitchen worktop with an open drawer below it. In the drawer stand seven teal spice tins with blank labels, and a hand lifts an eighth tin, an orange one, out of it. On the worktop lie a magnifying glass with a wooden handle and five glass jars with teal contents in a row.

Cookbook: Add a Lookup Field to a Maximo Mobile Page

Maximo Mobile Cookbook - This article is part of a series.
Part 3: This Article
A lookup field needs three pieces and no code: a datasource for the choices, the lookup, and an input that names it. The input writes the picked value into the record by itself. This recipe lets the user pick the location of a work order from 427 locations, and it shows what the lookup asks Maximo for.

MAS 9.2 series cookbook

It is the third recipe on the same work order page, after a field and a dialog. We ran every step on our test system, on the MAS 9.2 series, and the complete page is at the end as a download. Dialogs and Lookups explains the elements.

What you need
#

  • The page from the first recipe, or any page with a datasource that holds one record.
  • The object structure that holds the choices. For locations it is mxapioperloc.

Step 1 · Add the attribute to the record’s schema
#

The work order has to carry the attribute the user will change. As in the first recipe, that is one line in the schema of the page’s datasource:

<attribute name="location" id="fs_k_lookup_a_loc"/>

Step 2 · Add a datasource for the choices
#

<maximo-datasource id="fs_k_lookup_locs" object-structure="mxapioperloc"
    where="siteid=&quot;BEDFORD&quot;" order-by="location"
    lookup-data="true" page-size="20" selection-mode="single">
  <schema id="fs_k_lookup_locs_s">
    <attribute name="location" unique-id="true" searchable="true" title="Location" id="fs_k_lookup_l_loc"/>
    <attribute name="description" searchable="true" title="Description" id="fs_k_lookup_l_desc"/>
  </schema>
</maximo-datasource>
AttributeWhat it does here
lookup-data="true"the datasource loads when the lookup opens. Before that we counted no request for it
selection-mode="single"the user picks one row
searchable="true"the attributes the search of the lookup looks into
whereonly the locations of one site

Step 3 · Add the lookup
#

A lookup is a dialog with a datasource, and it sits in the <dialogs> of the page:

<dialogs id="fs_k_lookup_dialogs">
  <lookup id="fs_k_lookup_dlg" datasource="fs_k_lookup_locs" lookup-heading="Pick a location"
      lookup-attributes="{['location','description']}" show-search="true" show-count="true"/>
</dialogs>

lookup-attributes names what each row shows. show-search and show-count add the search box and the count of records.

Step 4 · Turn the field into an input with the lookup
#

<smart-input id="fs_k_lookup_si" label="Location" value="{fs_k_lookup_wo.item.location}"
    enable-lookup-buttongroup="true" select-lookup-attribute="location" lookup="fs_k_lookup_dlg"/>

Three attributes do the work. lookup names the lookup of Step 3. enable-lookup-buttongroup draws the button with the magnifying glass beside the input. select-lookup-attribute names the attribute of the picked row that goes into the value.

The properties panel of the MAF editor for the smart-input fs_k_lookup_si. Under “Set”: id, label “Location”, value bound to the location of the work order, enable-lookup-buttongroup ticked true, select-lookup-attribute “location”, and lookup “fs_k_lookup_dlg”. Below it “Required: none missing”.
The three attributes that turn an input into a lookup field, in the properties panel of our MAF editor

Step 5 · Build and try it
#

yarn clean && yarn build:mobile
Four phone frames. First, the work order page with an input “Location” that holds BR200 and a round button with a magnifying glass. Second, the lookup “Pick a location” with 427 records and a search box, its rows starting with 764750 Fort Collins Main Office. Third, the same lookup after a search for “boiler”: 5 records, among them BR300 Boiler Room Reciprocating Compressor. Fourth, the page again with BR300 in the input and the line “On the record: location BR300”.
The input, the lookup, a search, and the picked value on the record

We read each request of this path in the browser:

MomentRequest to mxapioperloc
the page opensnone
the lookup opensone, with oslc.where=siteid="BEDFORD" and oslc.select=location,description. The lookup showed 427 records
a search for “boiler”one, with oslc.searchTerms=boiler and searchAttributes=location,description. It took 229 milliseconds and left 5 records

The search runs on the server, over the two attributes the schema marks as searchable. So the search covers all 427 locations, whatever the lookup has loaded. One detail differs from the page: the request asked for a page size of 40, where the datasource says 20.

After the pick, the input and the record held BR300. The server still held BR200. A lookup changes the record in the app, and a save sends it, as in the dialog recipe.

What we left out
#

We first wrote the page with a lookup-map on the attribute, with two returns: the location, and the description into a local attribute. The location arrived, and the local attribute stayed empty in our run. Without any lookup-map the pick filled the location just the same. So this recipe keeps to the one attribute and to select-lookup-attribute.

The same places in an IBM app
#

In an app you duplicated from IBM, lookups sit in the <dialogs> of their page or at app level. The Technician app of the 9.2 series marks 25 of its datasources with lookup-data="true", like ours. A large table such as assets wants a where or a saved query that narrows it. BEDFORD has 427 locations and more than 31,000 assets on our system.

Download
#

The files of this recipe: the page we start from and the page with the lookup field.

This recipe as a PDF, to print or to read offline.

What to read next#

Forms and Input Fields covers smart-input with its other kinds, and Dialogs and Lookups covers selection modes and headings of a lookup.


IBM documents the elements of this recipe in the product itself. In the Application Configuration application, open the ? menu and choose Component Documentation for lookup, smart-input and maximo-datasource.

Maximo Mobile Cookbook - This article is part of a series.
Part 3: This Article