↓ Skip to main content
An ink and watercolour drawing of a kitchen shelf with five glass jars of teal contents in a row, each with a blank paper tag. A hand sets a sixth jar with orange contents into the gap between the fourth and the fifth. On the worktop below lie an open recipe book with blank pages, a pencil and a wooden spoon.

Cookbook: Add a Field to a Maximo Mobile Page

Maximo Mobile Cookbook - This article is part of a series.
Part 1: This Article
A new field on a Maximo Mobile page needs two edits: an attribute in the schema of the datasource, and the field itself. Forget the first one and nothing warns you. The build passes, the page loads, and the field shows a striped bar that looks like a value on its way. That value never arrives.

MAS 9.2 series cookbook

This recipe adds the GL account of a work order to a detail page. We ran every step on our test system, on the MAS 9.2 series, and the complete pages are at the end as a download. It builds on Datasource Basics and Data Binding.

What you need
#

  • An app of your own that builds on your machine. Hello World gets you one.
  • The page you want to change, and the datasource that feeds it.
  • The name of the attribute in the object structure. Step 1 finds it.

The page we start from
#

Our page shows work order 1221 with five fields. The datasource reads one record from the object structure mxapiwodetail, and its schema names six attributes:

<maximo-datasource id="fs_k_start_wo" object-structure="mxapiwodetail"
    where="wonum=&quot;1221&quot; and siteid=&quot;BEDFORD&quot;" page-size="1">
  <schema id="fs_k_start_wo_s">
    <attribute name="wonum" unique-id="true" id="fs_k_start_a_wonum"/>
    <attribute name="description" id="fs_k_start_a_desc"/>
    <attribute name="status" id="fs_k_start_a_status"/>
    <attribute name="status_description" id="fs_k_start_a_statusd"/>
    <attribute name="worktype" id="fs_k_start_a_worktype"/>
    <attribute name="wopriority" id="fs_k_start_a_prio"/>
  </schema>
</maximo-datasource>

Each field binds to one of them through the current record of the datasource:

<field id="fs_k_start_f_worktype" label="Work type" value="{fs_k_start_wo.item.worktype}"/>
<field id="fs_k_start_f_prio" label="Priority" value="{fs_k_start_wo.item.wopriority}"/>

Step 1 · Find the exact name of the attribute
#

The schema takes the name the object structure uses, letter for letter. For the GL account of a work order that name is glaccount. The object structure MXAPIWODETAIL has 660 attributes on our system, so we search for it. Our MAF editor lists them in its Data tab:

The Data tab of the MAF editor on the object structure MXAPIWODETAIL, read from Manage in 206 milliseconds. Under “Attributes · 660, 34 required” the search box holds “glacc”, and one row is left: glaccount, type GL 23. Below it the child objects and relationships begin with assignment.
One of 660: the attribute glaccount of MXAPIWODETAIL, with its type, in the Data tab of our MAF editor

Without the editor, the Object Structures application in Manage shows the same list, and so does a request to the API that selects the attribute.

Step 2 · Add the attribute to the schema
#

One line, inside the <schema> of the datasource that feeds the page:

    <attribute name="wopriority" id="fs_k_field_a_prio"/>
    <attribute name="glaccount" id="fs_k_field_a_gl"/>
  </schema>

The id has to be unique in the whole app. The name is the one from Step 1.

The schema is the request. The datasource asks Maximo for the attributes of its schema and for nothing else. We read the request of both versions of the page in the browser:

Pageoslc.select in the request
beforewonum,description,status,status_description,worktype,wopriority
with the attributewonum,description,status,status_description,worktype,wopriority,glaccount

On a device the same list decides what the app downloads for offline work. An attribute outside the schema is on no device.

Step 3 · Add the field to the page
#

One more line, between its two neighbours:

<field id="fs_k_field_f_worktype" label="Work type" value="{fs_k_field_wo.item.worktype}"/>
<field id="fs_k_field_f_gl" label="GL account" value="{fs_k_field_wo.item.glaccount}"/>
<field id="fs_k_field_f_prio" label="Priority" value="{fs_k_field_wo.item.wopriority}"/>

The binding names the datasource whose schema you changed in Step 2, then item, then the attribute. <field> shows a value. For a value the user may change, the element is <smart-input>, and Forms and Input Fields covers it.

Step 4 · Build and look
#

yarn clean && yarn build:mobile

The clean matters: a second build without it finds nothing changed and checks nothing. Then open the page in the preview.

Three phone frames of the same detail page of work order 1221. Left, the page we start from: work order, description, status, work type and priority. Middle, with the attribute and the field: a sixth line reads 6200-200-200, GL account. Right, the field without its attribute: in place of the value a grey striped bar, with the label GL account under it.
Before, after, and the mistake: the field without its attribute draws a striped bar

The middle frame is the result: 6200-200-200, the GL account of the work order.

The mistakes that pass the build
#

We made three mistakes on purpose, each on its own copy of the page.

MistakeBuildWhat the page shows
The field without the attribute in the schemapasses, no warning for ita striped bar in place of the value, still there after 25 seconds
A misspelled name in the schema, glacountpasses, no warning for itthe same striped bar. Maximo answered 200 and left the unknown name out
An id used twicestops with exit code 1nothing, and the message names the id

Only the third one stops you:

[ERROR]: Duplicate id: 'fs_k_dup_f_prio', detected in element: field ...

The first two are the dangerous ones. The striped bar looks like a value that is still loading, so the page seems slow where it is wrong. Our MAF editor marks the first mistake before any build, at the binding:

The code view of the MAF editor on the page with the mistake. Line 24 carries a yellow warning triangle, and a wavy line sits under “glaccount” in the binding of the field.
The binding to an attribute the schema does not select, marked in our MAF editor

Its finding reads: “The binding reads fs_k_miss_wo.item.glaccount, and the datasource fs_k_miss_wo does not select glaccount in its schema, so the field stays empty.” When a new field stays empty, look at the schema first, and compare the name with the object structure letter for letter.

The same places in an IBM app
#

In an app you duplicated from IBM, the two edits go to the same kind of place. In the Technician app of the 9.2 series the datasources sit in src/app.xml, and most of the page markup sits in fragments under src/maml/pages. Find the page, read which datasource its fields bind to, and add the attribute to that datasource’s schema. The Technician app has 14 datasources on the work order structure alone, and only the one in the binding counts.

Download
#

The three pages of this recipe: the page we start from, the page with the field, and the page with the mistake.

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

What to read next#

The next recipe adds a dialog to the same page. Datasource Basics explains what else a schema decides, and MAML Basics explains why a warning ships.


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

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