Adding queries to mobile apps

To enable mobile users to retrieve work list records from the server, you must add at least one query to each mobile app. You add queries to a mobile app by including them in the application definition file. You can also add queries by using the Anywhere Administration application if it is enabled.

Before you begin

You can add queries for the following apps:
  • Asset Audit
  • Asset Data Manager
  • Inspection
  • Service Request
  • Work Approval
  • Work Execution
You cannot add queries for the following apps:
  • Issues and Returns
  • Physical Count
  • Transfers and Receiving
The queries that you want to implement in the mobile application must be saved as public queries in Maximo® Asset Management.

About this task

In the application definition, you add queries to the specifications for the work list view and the primary resource. Each query must correspond to, and have the same name as, a public query in Maximo Asset Management. The public query, in turn, corresponds to a query in the service provider for the primary resource.

Each application definition includes three system queries, Records Created Locally, Records with Errors, and Search Results, that are used for system functions in the mobile app. You must not remove or modify the code for these queries.

Procedure

  1. In the Anywhere\MaximoAnywhere\apps\app_name\artifact directory, open the app.xml file with an XML editor.
  2. Add a query to the work list view. The work list view is the first view that is defined in the UI section of the application definition.
    1. In the <queries> element for the work list view, add a child element called <query>.
    2. Use the queryBase attribute to specify the name of the public query in Maximo Asset Management. The query name is case sensitive.
    3. Use the label attribute to specify the query label that is displayed in the work list menu.
    4. Optional: To define this query as the default query for the work list view, specify the query label as the value of the label attribute for the parent <view> element.
    In this example, three queries are added to the work list view for the Work Execution app:
    <view id="WorkExecution.WorkItemsView" label="Work I Own"
    				saveonshow="true"
    	<queries resource="workOrder">
    		<query label="Work I Own" queryBase name="WorkIOwn">
    		<query label="Assigned to My Labor" queryBase name="WorkforMyLabor">
    		<query label="Work Assigned to My Crew" queryBase name="WorkforMyCrew">
    		<...>
    	</queries>
    	<...>
    </view>
  3. Add the query that you specified in step 2 to the primary resource. The primary resource is the first resource that is defined in the data section of the application definition.
    1. In the <queryBases> element for the primary resource, add a child element called queryBase.
    2. Use the name attribute to specify the name of the public query in Maximo. The query name is case sensitive.
    3. Use the queryUri attribute to specify how to retrieve the query records from Maximo.
    In this example, three queries are added to the primary resource, workOrder, for the Work Execution app:
    <resource providedBy="/oslc/sp/WorkManagement" 
     describedBy="http://jazz.net/ns/ism/work/
    	smarter_physical_infrastucture#WorkOrder"
     name="workOrder" pageSize="100" 
    	class="application.business.WorkOrderObject">
    	<...>
    	<queryBases>
    		<queryBase name="WorkIOwn" queryUri="/oslc/os/oslcwodetail?savedQuery=WorkIOwn">
    		<queryBase name="WorkforMyLabor" queryUri="/oslc/os/oslcwodetail?savedQuery=WorkforMyLabor">
    		<queryBase name="WorkforMyCrew" queryUri="/oslc/os/oslcwodetail?savedQuery=WorkforMyCrew">
    	</queryBases>
    	<...>
    </resource>

  4. Save the file.
  5. Build and deploy the application.

What to do next

Log in to the application and check that the queries that you added appear in the work list menu. Verify that the result set is the same when you run the query in the provider application and in the mobile app.