MAS 9.2 series cheatsheet
Every count of requests on this page is measured on our test system, on the MAS 9.2 series, in the browser preview of our Components Explorer. The examples read work orders through the object structure mxapiwodetail.
The declaration#
<maximo-datasource id="fs_d_load_bound" object-structure="mxapiwodetail"
where="siteid="BEDFORD"" order-by="wonum" page-size="3" selection-mode="none">
<schema id="fs_d_load_bound_s">
<attribute name="wonum" unique-id="true" id="fs_d_load_bound_a_wonum"/>
<attribute name="description" id="fs_d_load_bound_a_description"/>
</schema>
</maximo-datasource>| Attribute | What it does | Worth knowing |
|---|---|---|
object-structure | the object structure the rows come from | a wrong name answers with HTTP 404 |
where | travels as oslc.where | quotes are written as "; a wrong attribute answers with HTTP 400 |
saved-query | a saved query of the object structure | combines with where: the rows are those that both allow; an administrator can change it without a new build |
order-by | travels as oslc.orderBy | order-by="wonum" sends +wonum |
page-size | the rows of a page | the sizes 3, 5, 10 and 20 asked Maximo for twice the number |
can-load | a condition that holds the datasource back | setting it to true starts no load; call load() |
pre-load="true" | loads when the page opens, with no component reading it | for rows that only your code uses |
include-counts="false" | drops collectioncount=1 from the request | no difference in time that we could measure |
controller | a class for the hooks of this datasource | gets each hook before the page controller |
selection-mode | none, single or multiple |
A json-datasource reads a file of the app. It names the file with src and its key with id-attribute, and it sends no request for any call in the tables of this page.
The guides for this section are Loading and Displaying Data, Maximo-Datasource vs. JSON-Datasource, Saved Queries and Filters.
The schema#
The schema is the select list of the request. An attribute that a binding reads has to be in it.
| In the schema | In the request | In the row |
|---|---|---|
description | description | item.description |
asset.description | asset.description | item.asset.description |
asset.description--assetdesc | asset.description--assetdesc | item.assetdesc |
rel.woactivity{taskid,description} | rel.woactivity{taskid,description} | item.woactivity, a list |
computedLine with computed-function | nothing | item.computedLine |
- A misspelled attribute passes the build. Maximo answers 200 and leaves the name out.
- A status needs
statusandstatus_description. searchable="true"puts an attribute into the text search.- A computed function runs more often than once per row. Keep it fast and free of side effects.
- A schema with 40 attributes gave an answer two and a half times as large as one with 4.
The guide for this section is the schema guide.
When it loads#
| The datasource is | First request |
|---|---|
bound to a list, or to a field through item | when the page draws |
| bound to nothing | none, until code calls load() |
bound only through state, as in a label for its count | none |
behind can-load that is false | none, also for load() |
marked with pre-load="true" | when the page opens |
The states#
Bind to them with {myDatasource.state.loading}.
| State | Meaning |
|---|---|
loading | true while a request runs |
hasData | false until the first load; true after a load, also when it found nothing |
itemCount | the rows the datasource holds |
totalCount | the rows that match in Maximo |
itemsChanged | true while a change is unsaved |
pageSize | the page size in use |
currentSearch | the text of the last search |
An empty list reads “No results found” for a datasource that never loaded and for a query that found nothing. hasData tells the two apart.
Reading#
const ds = this.page.findDatasource('fs_d_load_free');
await ds.load();| Call | Requests on a loaded datasource | Note |
|---|---|---|
load() | 0 | keeps the rows it has |
loadIfNecessary() | 0 | returns at once, with true when it started a load |
load({noCache: true}) | 1 | |
forceReload() | 1 | the call to see a change of the server |
loadRange(ds.items.length, 20) | 0 or 1 | takes the reserve first, then asks for the next page |
updatePageSize(100), then forceReload() | 1 | the request asks for the new size |
A list that scrolls to its end loads the next rows by itself. One request serves two screens of rows.
The guide for this section is Pagination and Performance.
Searching and filtering#
| Call | Runs | Sends |
|---|---|---|
search('pump') | in Maximo | oslc.searchTerms=pump over the searchable attributes |
search('pump', ['description']) | in Maximo | the same, over the named attributes |
search('') | in Maximo | the request without a search text |
setQBE('status', '=', 'APPR') | nowhere yet | nothing, it only stages the filter |
searchQBE() | in Maximo | the staged filters inside oslc.where |
clearQBE(), then searchQBE() | in Maximo | the request without the filters |
applyInMemoryFilter((item) => …) | in the app | nothing; it sees the loaded rows only |
search('pump', undefined, true) | in the app | nothing; it sees the loaded rows only |
clearInMemoryFilter() | in the app | nothing; it also undoes a search in memory |
- A search and a filter by column combine in one request.
- A second search with the same text sends nothing, also when its list of attributes differs.
search('')does not undo a search in memory.- In a list, the search box sends its request on the Enter key.
- For the signed-in user,
oslc.whereknows"-userid-","-personid-"and"-laborcode-".&USERNAME&matched no row.
The guide for this section is Search and Filtering.
Changing and saving#
ds.items[0].wopriority = 3;
const result = await ds.save();
if (result && result.error) {
return; // unsaved, and the user has seen the message
}| Call | Requests | What happens |
|---|---|---|
| a changed value | 0 | itemsChanged turns true, onValueChanged runs |
save() with a change | 1 | a POST to the record with x-method-override: PATCH; the body has the changed attribute and three technical keys |
save() without a change | 0 | returns at once |
undoAll() | 0 | takes back every unsaved change |
- A refused save does not throw.
save()returns an object witherror, and the framework shows the message of Maximo in a dialog. - After a refused save the wrong value is still in the record, and
itemsChangedis still true. - A save over a record that another user changed goes through. Maximo merges by attribute, and for the same attribute the last save wins.
- On a
json-datasource,save()sends nothing, and the value lasts until the app reloads.
The guide for this section is Saving and Updating Data.
The hooks of a datasource controller#
| Hook | Runs |
|---|---|
onDatasourceInitialized(ds) | once, when the page of the datasource first opens |
onBeforeLoadData(ds) | before every load |
onAfterLoadData(ds, items) | after every load, with the rows |
onValueChanged | for every changed value, also for values that a save brings back |
onBeforeSaveData | before the request of a save |
onAfterSaveData | after the answer of a save |
onSaveDataFailed | when Maximo refuses a save |
A hook of a datasource also reaches the page controller and the application controller, when they have a method of the same name.
The guides for this section are Using Lifecycle Hooks Correctly, Controller Architecture Overview.
This page as a PDF, to print or to keep beside the keyboard.
IBM documents <maximo-datasource>, <json-datasource>, <schema> and <attribute> in the product itself. In the Application Configuration application, open the ? menu and choose Component Documentation.
