I need to get this published to our community but below is how I added service & service group on WO. These two fields are dependent on one another and you're able to pick a service that will set the service group and when service group is set, the lookup for service is dependent on it.
Add to dsCreateWo:
<attribute name="commodity" />
<attribute name="commoditygroup" />
Add new lookup datasource:
<maximo-datasource id="commodityLookupDS" lookup-data="true" object-structure="MXAPICOMMODITY" selection-mode="single" saved-query="emxcommodity">
<schema >
<attribute name="commodity" searchable="true" />
<attribute name="parent" searchable="true" />
<attribute name="description" searchable="true" />
<attribute name="commoditiesid" unique-id="true" />
</schema>
</maximo-datasource>
Add new lookups
<lookup-with-filter id="commodityLookup" width="99" datasource="commodityLookupDS" show-search="true" on-item-click="selectCommodity" lookup-attributes="{['commodity','description','parent']}" show-count="true" lookup-heading="Service" />
<lookup-with-filter id="commodityGroupLookup" width="99" datasource="commodityLookupDS" show-search="true" on-item-click="selectCommodityGroup" lookup-attributes="{['commodity','description']}" show-count="true" lookup-heading="Service Group" />
Display the inputs on the WO creation page
<box direction="row" children-sizes="50" fill-parent="true" fill-child="true" padding-bottom=".5" padding-top=".5" >
<smart-input label="Service Group" theme="dark" placeholder="Service Group" value="{dsCreateWo.item.commoditygroup}" select-lookup-attribute="commodity" on-smart-lookup-click="showCommodityGroupLookup" on-smart-lookup-click-arg="{{'page':page,'item':dsCreateWo.item}}" enable-lookup-buttongroup="true" />
<smart-input label="Service" theme="dark" placeholder="Service" value="{dsCreateWo.item.commodity}" select-lookup-attribute="commodity" on-smart-lookup-click="showCommodityLookup" on-smart-lookup-click-arg="{{'page':page,'item':dsCreateWo.item}}" enable-lookup-buttongroup="true" />
</box>
JavaScript for the AppCustomization.js
showCommodityGroupLookup(event)
{
let commodityDs=this.app.findDatasource("commodityLookupDS");
commodityDs.clearState();
commodityDs.initializeQbe();
commodityDs.setQBE("parent","=","null");
commodityDs.searchQBE();
event.page.showDialog("commodityGroupLookup");
}
showCommodityLookup(event)
{
let commodityDs=this.app.findDatasource("commodityLookupDS");
commodityDs.clearState();
commodityDs.initializeQbe();
if (event.item.commoditygroup)
{
commodityDs.setQBE("parent","=",event.item.commoditygroup);
}else{
commodityDs.setQBE("parent","!=","null");
}
commodityDs.searchQBE();
event.page.showDialog("commodityLookup");
}
async selectCommodity(event)
{
let dsCreateWo = this.app.findDatasource("dsCreateWo");
if (!dsCreateWo.item.commoditygroup)
{
dsCreateWo.item.commoditygroup=event.parent;
}
dsCreateWo.item.commodity=event.commodity;
}
async selectCommodityGroup(event)
{
let dsCreateWo = this.app.findDatasource("dsCreateWo");
if (dsCreateWo.item.commodity && dsCreateWo.item.commoditygroup!=event.commodity)
{
// Clear out existing service
dsCreateWo.item.commodity=null;
}
dsCreateWo.item.commoditygroup=event.commodity;
}
------------------------------
Steven Shull
------------------------------