You are on page 1of 8

How to create Maximo child/related objects on IBM Maximo

Anywhere
Author: Ana Biazetti

In my previous blog post, How to add a Maximo related object to IBM Maximo Anywhere, I
provided an example for adding a Maximo related object into a Maximo Anywhere app user
interface (UI). The example added the communications log object, which is related to the work
order, to the Maximo Anywhere Work Execution app. This included:
A view to show the list of communication logs that are related to the work order
A view to show the details of each communication log

This document will build upon that scenario by allowing new communication log records to be
created through the Work Execution app and saved to Maximo, as expected. This exercise
includes:
a new view for the user to input the values for the new commlog
a button on the Work Order Detail View as well as on the CommLogList View to add new
commlog records
a javaScript handler class to include all the handler methods for initializing and validating
the views
a javaScript business object class to initialize and validate new commlog instances

The sections below cover the steps needed to accomplish this. Make sure you have the previous
exercise (How to add a Maximo related object to IBM Maximo Anywhere) working before you start
the steps below.

Step 1. Make changes in Maximo to allow OSLC to work properly with commlog as a record
that can be created by Maximo Anywhere

Step 1.1 In Maximo, add anywhererefid to the commlog object


Maximo Anywhere requires a new attribute to be added to the related/child object in Maximo such
that it can identify and relate that new record in the response from Maximo with the one recently
created locally (which does not have the Maximo assigned id yet). This attribute is called
anywhererefid.

1. In the Database Configuration application, open the commlog object


2. Add an attribute for anywhererefid with BIGINT type. Save.
3. Apply configuration changes (Admin mode on, Apply config Changes, Admin mode off)

Step 2.1 Some related records might need adjustments on the OSLC Object
Structure
This step is not required for all types of related records/child records. It is only required for objects
that have autokeys that are also keys on the record.

In this example, commlogid is a required key for commlog records, and it should be restricted
(meaning, not copied from OSLC requests) when creating new records.
To restrict the commlogid:
1. Go To > Integration Framework > Object Structures
2. Find oslcwodetail
3. Select Action > Inbound Setting Restrictions
4. Filter on commlog. Override and mark the commlogid field as restrictedfield.

.
This step is required because when Maximo Anywhere sends transactions to create commlog
records as children of a given workorder, OSLC must receive the commlogid (because it is a
required key)., It then must restrict it to allow Maximo to autokey its value on the record.

Step 2. Import the updated OSLC Resource into the Maximo Anywhere environment

/AnywhereWorkManagement/anywhere-rdfs-puller.xml should already have commLog as a


resource to be downloaded.
Run AnywhereWorkManager/anywhere-rdfs-puller.xml with parameters (make sure you specify
user/password). For more details, see this KnowledgeCenter section.
Make sure the commlog shape doc under: /AnywhereWorkManagement/oslc-
docs/resources/rdf/oslc/shapes/oslcwodetail/commlog/commlog is updated and includes the
new attribute.

Step 3. Update the app.xml artifact for the WorkExecution App


Step 3.1 In the View section, at the end of WO Details View, add the button to
create new commlogs by replacing the Communications Log groupitem with the
following:
<group>
<groupitem transitionTo="WorkExecution.CommLogListView" layout="Item1Count1Button1">
<text value="Comm Log" editable="false" layoutInsertAt="item1"
cssClass="relatedRecords" />
<text resourceAttribute="commloglistsize" editable="false"
layoutInsertAt="count1"> </text>
<button label="Create Comm Log Entry" image="action_addNew_OFF.png"
transitionTo="WorkExecution.NewCommLogView" layoutInsertAt="button1">
<eventHandlers>
<eventHandler event="render" method="enableAddCommLogButton"
class="application.customerExtensions.CommLogHandler" />
</eventHandlers>
</button>
</groupitem>
</group>

Step 3.2 In the View section, CommLogListView, add the action to create new
CommLog records:
<actions>
<action label="Create Comm Log Entry" transitionTo="WorkExecution.NewCommLogView"
image="header_add_OFF.png">
<eventHandlers>
<eventHandler event="render" method="enableAddCommLogButton"
class="application.customerExtensions.CommLogHandler" />
</eventHandlers>
</action>
</actions>

Step 3.3 In the View section, define NewCommLogView:


<!-- Define Comm Log Entry view -->
<view id="WorkExecution.NewCommLogView" label="Comm Log Entry"
showOverflow="false">
<requiredResources>
<requiredResource name="workOrder">
<requiredAttribute name="commloglist" />
</requiredResource>
</requiredResources>
<container resource="workOrder" attribute="commloglist">
<group>
<groupitem>
<text resourceAttribute="createdate" editable="false" />
</groupitem>
<groupitem>
<text label="Created By" resourceAttribute="createby" editable="false" />
</groupitem>
<groupitem>
<text label="Send To" resourceAttribute="sendto" editable="true"
placeHolder="Tap to enter" />
</groupitem>
<groupitem>
<text label="Subject" resourceAttribute="subject" editable="true"
placeHolder="Tap to enter" />
</groupitem>
<groupitem>
<text label="Message" resourceAttribute="message" editable="true"
placeHolder="Tap to enter" />
</groupitem>
</group>
</container>
<footer>
<button label="Cancel">
<eventHandlers>
<eventHandler event="click" method="discardNewCommLogEntry"
class="application.customerExtensions.CommLogHandler" />
</eventHandlers>
</button>
<button label="Create" cssClass="mblPrimaryButton">
<eventHandlers>
<eventHandler event="click" method="commitCommLogEntry"
class="application.customerExtensions.CommLogHandler" />
</eventHandlers>
</button>
</footer>
<eventHandlers>
<eventHandler event="initialize" method="initNewCommLogEntry"
class="application.customerExtensions.CommLogHandler" />
<eventHandler event="cleanup" method="handleBackButtonClick"
class="application.customerExtensions.CommLogHandler" />
<eventHandler event="show" method="showFooter"
class="application.customerExtensions.CommLogHandler" />
</eventHandlers>
</view>

Step 3.4 In the View section, CommLogDetailView, add the editableView tag:
<view id="WorkExecution.CommLogDetailView" label="Communication Log Entry"
editableView="WorkExecution.NewCommLogView">

Step 3.5 In the data section, commLogResource, add the required attrs to
commLogResource:
<attribute name="anywhereRefId" describedByProperty="spi_wm:anywhererefid" />
<attribute name="commlogid" describedByProperty="spi_wm:commlogid" />

Make sure of the case for the anywhereRefId attribute. The Maximo Anywhere platform depends
on this attribute being defined with this case.

The commlogid is only needed because we will be creating commlog records that have this id as a
required attribute. Other related/children records may not need an id to be added.
Step 4. Create the CommLogHandler and CommLogObject javaScript classes
1. Copy the provided CommLogHandler.js to:
/AnywhereWorkManager/apps/WorkExecution/common/js/application/customerExtensions/Com
mLogHandler.js
2. Copy the provided to CommLogObject to:
/AnywhereWorkManager/apps/WorkExecution/common/js/application/customerExtensions/CommL
ogObject.js

Results
After rebuilding the Work Execution app, you should see the new + buttons on both the
WorkOrder Details view as well as on the CommLog List View, and you should be able to add new
commlogs by clicking on them:
In summary, you can create Maximo related objects in Maximo Anywhere through the use of
configuration and customization. For more information on this and other Maximo Anywhere
configuration examples, please see this link.

In my next posts, I will cover additional examples of configurations in Maximo Anywhere.


I look forward to hearing about your own configuration scenarios and suggestions. Connect with me
here or on Twitter @abiazett.

You might also like