Hi Priya,
You're missing the !
on your return on woStatusFilter1
.
return !['ENROUTE','INPRG','REJECT','REVIEWED','WAITINFO','CAN','ABINS','DEFERRED','DOCD','ENROUTE','INPRG','WAPPR','WRKT','WSCH','CLOSE','WPCOND','IN REVIEW','WMATL','RELEASED','RETURN','NOTCOMP','CCOMP','HOLD'].includes(item.value);
The filter function should validate the items to be removed from the datasource.
------------------------------
Maycon Belfort
Consultant
BPD Zenith
Melbourne
Australia
------------------------------
Original Message:
Sent: Mon February 12, 2024 12:26 AM
From: Priya Dharmapurikar
Subject: Removing unwanted status from the Mobile workorder Status list.
Hi All,
We are using below code to remove the unwanted workorder status from the Workorder Status list from Maximo Mobile.
We are observing that this code is not behaving uniformly.
woStatusFilter1(item)
{
// Because this will return items to delete, we need the "inverse" of our desired results.
return ['ENROUTE','INPRG','REJECT','REVIEWED','WAITINFO','CAN','ABINS','DEFERRED','DOCD','ENROUTE','INPRG','WAPPR','WRKT','WSCH','CLOSE','WPCOND','IN REVIEW','WMATL','RELEASED','RETURN','NOTCOMP','CCOMP','HOLD'].includes(item.value);
}
async onAfterLoadData(dataSource,items)
{
if (dataSource && dataSource.name==="dsstatusDomainList")
{
// Ensure we have at least one record
if (items && items.length>0)
{
let filteredItems=items.filter(this.woStatusFilter1);
await dataSource.deleteItems(filteredItems);
}
}
}
We are seeing on some occasions it is still displaying the whole list with the unwanted status. On the second click it executes the code and shows the correct list. We do not know why there is delay in executing the code and how can we avoid the frequent occasions when it is happening.
Please let us know if we are missing something here.
------------------------------
Priya Dharmapurikar
------------------------------