Adding related records to mobile apps

Objects that you can add as related records to mobile apps are defined by OSLC Resource Description Framework (RDF) files. In Maximo® Asset Management, you can add a related object to an OSLC resource and use the metadata for the object as a related record in a Maximo Anywhere app.

Before you begin

Run the RDF puller to import OSLC resources into Maximo Anywhere.

About this task

When you add a related or child object in Maximo Asset Management to an OSLC object structure that exists in Maximo Anywhere, you update the parent OSLC resource to include the child object. To use the child object as a related record in a mobile app, you import the RDF from Maximo Asset Management to Maximo Anywhere. After you import the RDF, you define the resource and the views for the related record in the app artifact files.

The resource for the child object must exist in the app.xml file so that the fields can appear in a mobile app. To show the related record, you update the app.xml file to add a view to show the details of the record and a view to show the list of records that are related to the mobile app.

For example, the communication log is a child object of the Work Order Maximo business object (MBO). A list of communication logs can be related to the Work Order. To use communication logs as related records on the Work Order Details view in the Technician app, you add the object for the communication log to the work order OSLC object structure and associated OSLC resource in Maximo Asset Management. You import the updated metadata into Maximo Anywhere and add the attribute for the communication log list to the app.xml file so that the records for the communication logs and their fields can appear the Work Order Details view.

Procedure

  1. In Maximo Asset Management, add the object for the related record to the OSLC resource.
    1. In the Object Structures application, open the object structure record that is associated with the resource that you want to add the object to.
    2. Add the child object as a source object.
    3. Specify the parent object and the relationship and save the record.
      The OSLC resource that is associated with the object structure is automatically updated to include the object.
    4. In the OSLC Resources application, find the OSLC resource and verify that the child object is added.

    For example, to add the object for the communication log, commlog object, to the work order resource, find the record for the oslcwodetail object structure. Add the commlog object as a source object. Specify WORKORDER as the parent object and specify COMMLOG as the relationship to the resource. In the OSLC Resources application, find the WORKORDER resource and verify that the COMMLOG object is added.

  2. Import the updated OSLC resource from Maximo Asset Management into Maximo Anywhere.
    1. Edit the anywhere-rdfs-puller.xml file and add the RDF name.
    2. Run the anywhere-rdfs-puller.xml file to import the RDF into the OSLC resources directory in Maximo Anywhere.
    3. Verify that the RDF is imported in the Anywhere\MaximoAnywhere\oslc-docs\resources\rdf\oslc directory.
    For example, edit the anywhere-rdfs-puller.xml file to add the commlog RDF.
    <target name="all" description="downloads all rdfs" />
    		<...>
    	<downloadOneRdf context="/oslc/shapes/oslcalndomain"  />
    	<downloadOneRdf context="/oslc/shapes/oslcwodetail/commlog" />
    </target>
    Run the anywhere-rdfs-puller.xml file to import the commlog RDF. Verify that the shape document for the commlog is imported into the Anywhere\MaximoAnywhere\oslc-docs\resources\rdf\oslcshapes\oslcwodetail\commlog directory.
  3. Define the attribute and the resource for the related record in the Data section of the app.xml file.
    1. Open the app.xml file and add the attribute for the related record to the OSLC resource.
      The attribute defines the related record that is available to use in the app.
    2. Add the resource for the related record.
      The resource describes the metadata for the fields that the related record uses.

    For example, add the attribute for the commlog to the work order resource to show the communication log in a child view of the Work Order Details view for the Technician app. The Work Order Details view references the workOrder resource.

    <resource providedBy="/oslc/sp/WorkManagement"
    			describedBy="http://jazz.net/ns/ism/work/smarter_physical_infrastructure#WorkOrder"
    			name="workOrder" pageSize="200" class="application.business.WorkOrderObject">
    	<attributes>
    		....
    		<attribute name="commloglist" describedByProperty="spi_wm:commlog"
    					describedByResource="commLogResource" />
    		....
    		<localAttribute name="commloglistsize" dataType="string"
    					persistent="false" />	
    	</attributes>
    	....
    </resource>
    Add the resource for the communication log with the fields to be used in the Technician app.
    <!-- Comm Log Resource -->
    <resource name="commLogResource">
    		<attributes>
    			<attribute name="createdate" describedByProperty="spi_wm:createdate" />
    			<attribute name="createby" describedByProperty="spi_wm:createby" />
    			<attribute name="subject" describedByProperty="spi_wm:subject" />
    			<attribute name="message" describedByProperty="spi_wm:message" />
    			<attribute name="sendfrom" describedByProperty="spi_wm:sendfrom" />
    			<attribute name="sendto" describedByProperty="spi_wm:sendto" />
    		</attributes>
    </resource>
    
  4. In the UI section of the app.xml file, create the view to show the details of the related record.
    1. Add a <view> element and specify the ID and label for the view.
    2. Define the resource for the view.
    3. Add the fields for the view.
    For example, to create the detail view for the communication log, specify the ID attribute as WorkExecution.CommLogDetailView in a new <view> element. The details view is called Communication Log Entry, and the following fields are added to the view as read-only fields:
    • Created By
    • Send To
    • Subject
    • Message
    The date and time that the communication log was created is also added.
    <!-- Define Comm Log Detail View -->
    		<view id="WorkExecution.CommLogDetailView" label="Communication Log Entry">
    			<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="false" />
    					</groupitem>
    					<groupitem>
    						<text label="Subject" resourceAttribute="subject" editable="false" />
    					</groupitem>
    					<groupitem>
    						<text label="Message" resourceAttribute="message" editable="false" />
    					</groupitem>
    		
    				</group>
    				<group>
    					<groupitem>
    						<lastupdatetext />
    					</groupitem>
    				</group>
    			</container>
    		</view>
  5. In the UI section of the app.xml file, create the view to show a list of related records for the mobile app.
    1. Add a <view> element and specify the ID and label for the view.
    2. Define the resource and attribute for the view.
    3. Add the fields for the view.
    4. Add a link to the details view.
    5. Specify the layout template name for the list view.
    For example, to create the list view for the communication log, specify the ID attribute as WorkExecution.CommLogView in a new <view> element. The list view is called Communications Log. The following fields are added to the view as read-only fields:
    • Created By
    • Send To
    • Subject
    The date and time that the communication log was created is also added.
    To access the Communication Log Entry details view from the Communications Log list view, enter the ID for the WorkExecution.CommLogDetailView to the transitionTo attribute. The layout for the view is called CommLogListItem.
    <!-- Define Comm Log List View --
    	<view id="WorkExecution.CommLogView" label="Communications Log" >
    		<requiredResources>
    			<requiredResource name="workOrder">
    				<requiredAttribute name="commloglist" />
    			</requiredResource>
    		</requiredResources>
    		<list resource="workOrder" attribute="commloglist"
    			transitionTo="WorkExecution.CommLogDetailView">
    			<sortOptions>
    				<sortOption label="Created Date" >
    					<sortAttribute name="createdate" direction="asc" />
    				</sortOption>
    				<sortOption label="Created By">
    					<sortAttribute name="createby" direction="asc" />
    				</sortOption>
    			</sortOptions>
    		<listItemTemplate layout="CommLogListItem">
    				<listtext resourceAttribute="createdate" layoutInsertAt="item1" />
    				<listtext resourceAttribute="createby" layoutInsertAt="item2" />
    				<listtext resourceAttribute="sendto" layoutInsertAt="item3" />
    				<listtext resourceAttribute="subject" layoutInsertAt="item4"
    					cssClass="bold textappearance-medium" />
    				</listItemTemplate>
    			</list>
    		</view>
  6. In the Anywhere\MaximoAnywhere\apps\app_name\artifact\layouts\templates\small directory, create the layout template for the list view.
    For example, to define the layout for the Communications Log view, create a layout file called CommLogListItem.xml in the Anywhere\MaximoAnywhere\apps\WorkExecution\artifact\layouts\templates\small directory and specify the structure for the layout.
    <layout width="100">
    	<row>
    		<column columnid="item1" colspan="4" />
    		<column columnid="item2" colspan="4" />
    		<column columnid="item3" colspan="4" />
    	</row>
    	<row>
    		<column columnid="item4" colspan="12"  />
    	</row>
    </layout>
  7. In the UI section of the app.xml file, add a field on the main view in the mobile app to access the related record.

    For example, to access the Communications Log list view from the Work Order Details view, add the list view to the <groupitem> element within the view.

    <view id="WorkExecution.WorkDetailView" label="Work Order Details" resource="workOrder">
    	.... 
    	<container resource="workOrder">	
    	....
    		<group>
    			<groupitem transitionTo="WorkExecution.CommLogView" layout="Item1Count1Button1">
    					<text value="Communications Log" editable="false" layoutInsertAt="item1"
    						cssClass="relatedRecords" />
    					<text resourceAttribute="commloglistsize" editable="false"
    						layoutInsertAt="count1"> 
    					</text>
    			</groupitem> 
    		</group>
    
    		<group>
    			<groupitem>
    				<lastupdatetext />
    			</groupitem>
    		</group>
    	</container>
    </view>
  8. Optional: To show the number of related records that are available from the main view, specify the variables for the list size and the attribute of the related record in the associated JavaScript file in the MaximoAnywhere\apps\WorkExecution\common\js\application\handlers directory.
    1. Specify the resource attribute of the related record in the attributes variable.
      The resource attribute for the related record must be defined in the OSLC resource in the app.xml file.
    2. Specify the resource attribute for the list size of the related record in the listSizeArray variable.
      The resource attribute for the list size must be defined as a local attribute in the OSLC resource in the app.xml file.
    For example, to show the number of communications logs for each work order on the Work Order Details view, add the following variables to the WODetailHandler.js file in the MaximoAnywhere\apps\WorkExecution\common\js\application\handlers directory:
    • Add the commloglistsize resource attribute to the listSizeArray variable.
    • Add the commloglist resource attribute to the attributes variable.
    var listSizeArray = ['tasklistsize', 'assignmentlistsize', 'materiallistsize', 
    										'toollistsize', 'actuallaborlistsize', 'actualmateriallistsize',
    									  'actualtoollistsize','workloglistsize', 'multiassetloclistsize', 
    										'attachmentssize', 'commloglistsize'];
    var attributes = ["tasklist", "assignmentlist", "materiallist", "toollist", "actuallaborlist", 
    								"actualmateriallist", "actualtoollist", "workloglist", "multiassetloclist", 
    								"attachments", "commloglist"];
  9. Save your changes.
    The app is built automatically.

What to do next

Build and deploy the app.