If you're talking that high, executing a count query I would think would be more efficient than iterating through the set even if that set is in memory.
As for async, the only way that could work is if you make the attribute persistent and it's typically not recommended to do that for count or other summary type fields. That can easily get out of sync with the actual count as users add/remove multiassetlocci records unless you're processing often. Initialize value on a non-persistent will only calculate when it's needed (IE when that value is trying to be displayed/referenced) and will be accurate at that point in time.
As Ruud mentions, formulas are an alternative instead of an initialize value automation script. It utilizes under the cover parts of the automation scripting framework but makes a more "Excel like" approach for administrators. It makes sense in certain use cases, especially when you have multiple fields that are involved in the calculation as you don't need to specifically build launch points for each attribute. I personally like the flexibility with a script here to determine the most efficient way to get the size.
------------------------------
Steven Shull
Director of Development
Projetech Inc
Cincinnati OH
------------------------------
Original Message:
Sent: Mon September 28, 2020 09:59 AM
From: User1971
Subject: Populate a multi-asset count field in WORKORDER?
Thanks. I'll look into your suggestions.
If the script did end up being slow, would this be a good scenario for using an asynchronous automation script?
We're considering using multi-assets for large GIS inspection programs. A single WO could have 10,000 multi-asset records.
Example: 10,000 sewer catchbasins in a single inspection program/WO.
Original Message:
Sent: Mon September 28, 2020 09:07 AM
From: Steven Shull
Subject: Populate a multi-asset count field in WORKORDER?
I would create a new non-persistent attribute on WORKORDER and an automation script with an attribute Initialize Value launch point on the attribute you created. From there, you'll need to decide whether you want to include the primary (IE the asset/location on the WO directly) or just the ones displayed in the MULTIASSETLOCCI table. Most people don't realize that the asset/location referenced on the WO is always added to MULTIASSETLOCCI so you will almost always have 1 entry in that table for every work order. I'm going to make the assumption you DON'T want to include the primary asset and based on your message that you don't want to include when it references a location (just references to an asset).
From there, you have a few different options depending on preference and need for accuracy. It's often advantageous to work with sets that already exist in memory because fewer database queries would be required. Especially if you only intend to display this in an app like WOTRACK where MULTIASSETLOCCI already exists and has been initialized. But, the caveat there is user filters can impact your results. If I filtered the MULTIASSETLOCCI table (looking for asset=123 for example) then my counts would be off if I used that same set. Or I would have to reset the set to clear the filter, which wouldn't save me anything and would be negative from a user perspective.
If you need absolute accuracy, you're best off executing a query or getting a set that won't exist in memory. If you're only trying to approximate, you're better off using something in memory as it should be faster for the user.
Getting the size of the set can be done a few different ways, but in general I like looping through the set if I have the records in memory. That would be accurate without executing another database query. Count will get you the actual size without iterating through the set, but if the query being executed is slow then this process will be slow because it has to execute that query again. getSize() isn't reliable so I don't use it for this purpose.
------------------------------
Steven Shull
Director of Development
Projetech Inc
Cincinnati OH
Original Message:
Sent: Sat September 26, 2020 05:49 PM
From: User1971
Subject: Populate a multi-asset count field in WORKORDER?
Maximo 7.6.1.2:
I plan to add a field to the WORKORDER table that would contain a count of the related assets in the MULTIASSETLOCCI table.
What would it take to populate such a field?
Thank you.
#Maximo
#AssetandFacilitiesManagement