Good feedback, especially on the implements. I don't think I've ever seen it used that way and I love avoiding an import (especially since I use this in a lot of scripts).
I also missed in your example that you weren't actually using count (you were just discussing the difference above) so I apologize for that. I read the top part and assumed that was in the solution. Your way avoids the performance impact and keeps the position of the set intact which makes sense on the list tab.
A lot of examples I see online use the count to determine how many records to iterate which can slow down the process, especially if the query takes a while to execute. In one time cases like this it probably isn't that big of a deal, but we dealt with a case where Anywhere lookup data was increased significantly because each assetspec was executing a count against assetattribute in addition to the query to get asset attribute. When you're pulling 500,000 specs even a 2 ms query per count will have a serious impact to performance.
------------------------------
Steven Shull
Director of Development
Projetech Inc
Cincinnati OH
------------------------------
Original Message:
Sent: Fri September 11, 2020 10:36 AM
From: Jason Uppenborn
Subject: List View script only works for the first 22 records in resultset
Since moveXxxx() changes the "current record" pointer, and we are talking about the user-facing MboSet in the List tab, I would prefer using getMbo(). Also, Mbo implements MboConstants, so you should be able to use mbo.NOACCESSCHECK
, saving an import but still achieving more readable code.
------------------------------
Blessings,
Jason Uppenborn
Sr. Technical Maximo Consultant
Ontracks Consulting
Original Message:
Sent: Fri September 11, 2020 10:20 AM
From: Steven Shull
Subject: List View script only works for the first 22 records in resultset
Agreed with Jason that your issue is probably with getSize() (that's burned me in the past). But when you don't need to know how many records, don't use getSize() or count(). Count is executing an additional database query and as you've found, getSize() isn't reliable. Just loop until you get to the end of the set. Just use this:
assetMbo=assetSet.moveFirst()
while assetMbo:
assetMbo.setValue(attrName,value,11L)
assetMbo=assetSet.moveNext()
I'd also be really cautious about 11L. You're suppressing validation and action with that which means that you can get bad values. If you are just trying to make it editable when it's read-only, use 2L instead (or import MboConstants and use MboConstants.NOACCESSCHECK).
------------------------------
Steven Shull
Director of Development
Projetech Inc
Cincinnati OH
Original Message:
Sent: Thu September 10, 2020 04:03 PM
From: User1971
Subject: List View script only works for the first 22 records in resultset
Maximo 7.6.1.2:
I have an automation script that I use to make mass updates to a specific field in the List View records.
Unfortunately, the updates are only being applied to the first 22 records in the resultset.
Does anyone know why it only works on the first 22 records?
Thanks.
--------------------------------------------------------------------------------------
from psdi.common.context import UIContext
from psdi.webclient.system.session import WebClientSessionManager
from psdi.webclient.system.controller import SessionContext, Utility, WebClientEvent
from java.lang.System import out
assetSet=service.webclientsession().getCurrentApp().getResultsBean().getMboSet()
attrName=mbo.getString("C_ATTRNAME")
value = mbo.getString("C_VAL")
for i in range(assetSet.getSize()):
mbo = assetSet.getMbo(i)
if not mbo is None:
mbo.setValue(attrName,value,11L)
c = UIContext.getCurrentContext().getWebClientSession()
Utility().sendEvent(WebClientEvent("dialogok", c.getCurrentPageId(), None, SessionContext(c)))
assetSet.save()
#Maximo
#AssetandFacilitiesManagement