Thanks, much appreciated.
Will help with the ground work for sure.
Cheers from New Zealand.
------------------------------
Richard Jackson
Asset Information and Systems Manager
Massey University
Palmerston North
New Zealand
------------------------------
Original Message:
Sent: Mon September 13, 2021 09:19 PM
From: User1971
Subject: Batch-delete records via Excel application import/export
Someone sent me these automation scripts recently. I haven't had a chance to test them, but I thought I'd share them anyway:
Script 1:
Replaces route stops with new route stops -- via a saved asset query
from psdi.mbo import Mbo
from psdi.mbo import MboSet
from psdi.security import UserInfo
from psdi.server import MXServer
mxserver = MXServer.getMXServer()
ui = mxserver.getSystemUserInfo()
route = mbo.getString("ROUTE")
#Script will execute when the user selects a saved query from a field in the route and hits save
if (route is not None and route!=""):
#Change: DESCRIPTION field to the field with the saved query name
savedQuery = mbo.getString("DESCRIPTION")
if (savedQuery is not None and savedQuery!=""):
querySet=mxserver.getMboSet("QUERY",ui)
#Change the app name as required
querySet.setWhere("clausename='"+savedQuery+"' and app='ASSET'")
querySet.reset()
if (querySet is not None and querySet.getMbo(0) is not None):
queryMbo = querySet.getMbo(0)
whereClause=queryMbo.getString("CLAUSE")
assetSet=mbo.getMboSet("ALLASSETS")
assetSet.setWhere(whereClause)
assetSet.reset()
assetMbo=assetSet.moveFirst()
newRSSet=mbo.getMboSet("ROUTE_STOP")
if (newRSSet is not None):
newRSSet.deleteAll()
while(assetMbo):
assetnum=assetMbo.getString("ASSETNUM")
newmbo=newRSSet.add()
#Add the fields for Route_Stop as per the requirement
newmbo.setValue("ASSETNUM",assetnum,11)
newmbo.setValue("ASSETLOCSITEID",assetMbo.getString("SITEID"),11)
newmbo.setValue("ASSETLOCORGID",assetMbo.getString("ORGID"),11)
newmbo.setValue("ASSETDESCRIPTION",assetMbo.getString("DESCRIPTION"),11)
newmbo.setValue("ASSETDESCRIPTION_LONGDESCRIPTION",assetMbo.getString("DESCRIPTION_LONGDESCRIPTION"),11)
#newmbo.getThisMboSet().save()
assetMbo=assetSet.moveNext()
Script 2:
Delete all the stops in route (not related to the script above)
from psdi.mbo import MboRemote
from psdi.mbo import Mbo
from psdi.mbo import MboSetRemote
from psdi.mbo import MboSet
routeStopSet = mbo.getMboSet("ROUTE_STOP")
if (not routeStopSet.isEmpty()) :
routeStopSet.deleteAll(2L)
mbo.getThisMboSet().save()
Original Message:
Sent: Mon September 13, 2021 09:10 PM
From: Richard Jackson
Subject: Batch-delete records via Excel application import/export
Yeah in the first instance we're looking to deploy as a one off manual button.
Users will still be able to add other Assets, or remove any they don't want included after the list is populated etc
Will see how this is received by end users and potentially develop from there.
------------------------------
Richard Jackson
Asset Information and Systems Manager
Massey University
Palmerston North
New Zealand
Original Message:
Sent: Mon September 13, 2021 08:55 PM
From: User1971
Subject: Batch-delete records via Excel application import/export
A related RFE here:
Dynamic routes (route stops based on SQL where clause)
And an old Community post here:
Dynamic Routes?
Original Message:
Sent: Mon September 13, 2021 05:53 PM
From: Richard Jackson
Subject: Batch-delete records via Excel application import/export
Ha I'm working on exactly this at the moment and I too decided to call it Dynamic Routes.
In my case I'm extending the application/xml design to have a tick box and a build route button.
I specify the location and asset classification to include and when I press build route it clears the routestops and rebuilds them with all assets that fit the criteria I've provided. It sorts by building name, then by level descending and then by room ascending, and spaces them 5 apart in the sequence numbers.
At some stage in the future I'd love for the route to be empty even, and this process be run at the PM WO generation process stage, so it's always pulling the most current list of applicable assets.
------------------------------
Richard Jackson
Asset Information and Systems Manager
Massey University
Palmerston North
New Zealand
Original Message:
Sent: Thu September 09, 2021 12:21 AM
From: User1971
Subject: Batch-delete records via Excel application import/export
Thanks Steven. That's a good approach.
FYI - I borrowed your wording and posted it as an IBM Idea (RFE) here: Dynamic routes (route stops based on SQL where clause) .
Feel free to let me know if there's anything I should change.
#Maximo
#AssetandFacilitiesManagement