Enable the use of work order classifications in Technician app
About this task
This guide walks through how to include the use of Classifications when creating a new work order record in Technician application.
Procedure
Step 1: Add a new datasource referencing the mxapiclassstructure object structure. This should be defined along with the other search datasources at the top level of the application (pages). This ensures that this datasource can be used on other pages, such as the edit page. Below is a saved query called “emxwoclass” but this can be changed to anything you add to the object structure to show the appropriate classifications.
<maximo-datasource id="classificationLookupDS" lookup-data="true" object-structure="mxapiclassstructure" offline-immediate-download="true" saved-query="emxwoclass" selection-mode="single" order-by="classificationid"><schema><attribute name="classstructureid"/><attribute name="classificationid" searchable="true"/><attribute name="classificationdesc"/><attribute name="hierarchypath"/><attribute name="description" searchable="true"/></schema></maximo-datasource>
Step 2: Add a new lookup. All lookups are defined at the page level, but this is not mandatory and would not be recommended for lookups like this. We recommend adding above / the block.
<dialogs id="demolookups"><lookup-with-filter lookup-heading="Classification" datasource="classificationLookupDS" id="classificationLookup" lookup-attributes="{['hierarchypath','classificationid','description']}"/></dialogs>
Step 3: In the “datasource” dsCreateWo, search for id=“dsCreateWo” and add the following attributes.
<attribute name="classstructureid" /><attribute name="hierarchypath" local="true"/>
Step 4: Add UI elements to display the hierarchy path and open the search page, locate the id “q55zy” and add the code below.
<box children-sizes="100" background-color="field-01" direction="row" fill-child="true" fill-parent="true" padding-bottom=".5" padding-top=".5" id="a1_z2883"><border-layout fill-parent="true" width="100%" padding="true" id="a1_b4_p6"><start direction="row" horizontal-overflow="hidden" vertical-align="center" width="60" shrink="0" id="a1_qx8e2"><field empty-field-placeholder="Select a classification" label="Hierarchy" value="{dsCreateWo.item.hierarchypath}" id="a1_r_xgy"/></start><end horizontal-align="end" vertical-align="center" direction="column" id="a1_wpewd"><button icon="Carbon:chevron--right" kind="ghost" on-click="openClassificationLookup" on-click-arg="{{'page':page,'app':app, 'item':dsCreateWo.item}}" padding="false" id="a1_w6n9m"/></end></border-layout>
Step 5: In AppCustomizations.js, we need to add an openClassificationLookup event to handle the chevron (arrow). Note that in the previous statement, in step 4, we provided the current page and the current record. This is important so that our openClassificationLookup event has the necessary arguments.
openClassificationLookup(event) {event.page.showLookup("classificationLookup", { targetItem: event.item, targetField: 'classstructureid', selectLookupAttribute: 'classstructureid' });}
Step 6: Since the framework currently only allows us to set 1 attribute of a lookup, we need to use the onValueChanged event to set the hierarchy path when classstructureid is set.
async onValueChanged(event) {let dataSource=event.datasource;if(event.field=="classstructureid") {let lookupDs=this.app.findDatasource("classificationLookupDS");await lookupDs.initializeQbe();lookupDs.setQBE("classstructureid","=",event.newValue);let records=await lookupDs.searchQBE();if(records.length==1) {event.item["hierarchypath"]=records[0].hierarchypath;
Step 7: Go to the application object structure in Maximo and locate the “mxapiclassstructure” object, create a new query using the name defined in step 1 “emxwoclass”, with “Query Type” = “osclause” and enable the Public flag. Classifications can be defined at the site level and not all classifications are valid for WORKORDER, so I used the following query clause as a starting point.
(siteid is null or siteid=(select defsite from maxuser where userid=:user)) and exists(select 1 from classusewith where classstructureid=classstructure.classstructureid and objectname='WORKORDER')
Step 8: In the Security application, confirm that your group has read access to the “MXAPICLASSSTRUCTURE” object.