This post is a third in a series that started with https://maximoplus.com/blog/getting-started-with-maximoplus/.

We already mentioned that MaximoPlus access Maximo directly from its server. Saving the Maximo data may be an expensive operation in Maximo, so MaximoPlus don't do it automatically. We need to use the standard API save function from MaximoPlus.

To illustrate how the save works in MaximoPlus, we will create a save button on the toolbar of our section page.

First, add the save function to the import parts of the page:

import { save } from "mplus-react";

Then create a function to operate on the main po application container:

const saveAction = () => {
  save("pocont");
};

Finally, add the Save button to the header of the screen:

  static navigationOptions = ({ navigatiopn }) => {
    const buttons = [{ key: "save", label: "Save", action: saveAction }];
    const iconMap = { save: "md-save" };
    return {
      headerTitle: "Details",
      headerRight: <HeaderActionButtons buttons={buttons} icons={iconMap} />
    };
  };

Now, try to find some editable record in the list, change a value, and press the save button. What did happen? Our current record went back to the first item in the list.

To understand why this has happened, remember that Maximo resets the MboSet after the saving, and sets its current row to zero. To get a more Maximo-like behavior, we need to introduce the concept of the Single Mbo Container.

Single Mbo container is the container bound to the MboSet with exactly one Mbo, the current Mbo of the parent container. Edit the Containers.js file and add the following:

import { AppContainer, SingleMboContainer, RelContainer } from "mplus-react";
...
 <SingleMboContainer id="posingle" container="pocont" />

The container attribute of the SingleMboContainer is the parent MboSet. When the current row changes in the parent Mbo Set, the SingleMboContainer current Mbo changes. However, all the changes we do on the Single Mbo Container don't affect the parent container. Edit the container attribute of the section to posingle, and change the save action to :

const saveAction = () => {
  save("posingle");
};

The SingleMboContainer is a recommended way to operate on Maximo data. Some functions, like Maximo Status Change (more about that in another blog post), will not work as expected unless on SingleMboContainer.

In  the next post, learn how to access the smart phone features from MaximoPlus.