This looks like a pretty solid solution. Another potential option is to use Data Restrictions and a Conditional Expression based on an Automation Script, but I'd probably prefer the Retrieve List path, as Data Restrictions can result in some unintended/unpredictable behavior in my experience.
Original Message:
Sent: 08-15-2024 23:07
From: Matt F
Subject: Limit Work Types to Specific Classifications or Classstrucureid?
Hi @Martin Fabra, which types did you try? I went with a Retrieve List as a test. In this case, I've hardcoded mappings between CLASSSTRUCTUREID and the WORKTYPE in my script. If there's no Asset, it'll show them all. It's late but I know there's another way to potentially grab these dynamically, or so my mind is telling me. Tagging a few others... @Steven Shull @Jade Warren @Tim Ferrill
Either way, I was able to get my desired results with the following Retrieve List Attribute Launch Point (WORKORDER.WORKTYPE) Script. There's definitely some additional testing required that I did not perform, but thought this might be a helpful start.
from psdi.mbo import MboConstants# Initialize listMboSet to handle scenarios where asset is NonelistMboSet = None# Ensure mbo is valid before performing any operationsif mbo is not None and mbo.isBasedOn("WORKORDER"): # Define the mapping between CLASSSTRUCTUREID and WORKTYPE mapping = { "1128": ["CM", "EM"], # "CLASSID2": ["WORKTYPE", "WORKTYPE"], #"CLASSID3": ["WORKTYPE", "WORKTYPE"], # Add more mappings as needed } # Get the asset's CLASSSTRUCTUREID only if the asset is not None asset = mbo.getMboSet("ASSET").getMbo(0) if asset is not None: classstructureid = asset.getString("CLASSSTRUCTUREID") # Get the list of allowed worktypes for this classstructureid allowed_worktypes = mapping.get(classstructureid, []) # Create a new MboSet to store the filtered WORKTYPEs worktypeSet = mbo.getMboSet("$WORKTYPE_LOOKUP", "WORKTYPE", "") worktypeSet.clear() # Iterate over the allowed worktypes and add them to the MboSet for worktype in allowed_worktypes: worktypeMbo = worktypeSet.addAtEnd() worktypeMbo.setValue("WORKTYPE", worktype, MboConstants.NOACCESSCHECK) # Set the filtered worktype set for the lookup listMboSet = worktypeSet else: # Handle scenario where asset is None listMboSet = mbo.getMboSet("$WORKTYPE_LOOKUP", "WORKTYPE", "1=1")# The script should return the MboSetRemote object directly for the Retrieve List eventif listMboSet is None: listMboSet = mbo.getMboSet("$WORKTYPE_LOOKUP", "WORKTYPE", "1=1")listMboSet
------------------------------
Matt F
Original Message:
Sent: 08-13-2024 10:42
From: Martin Fabra
Subject: Limit Work Types to Specific Classifications or Classstrucureid?
Hi @Danny Richardson!
I tried to make scripts but they never worked... the java class FldWorkType.class always prevails and takes control. I was unable to restrict the worktype based on the classstructureid of the WO's assets . I imagine that if it is not possible (maybe someone can help you with a script) via script, it would be necessary to modify the java class.
Regards!
------------------------------
Martin Fabra
ARSAT S.A. - Actively seeking employment
Original Message:
Sent: 08-02-2024 12:40
From: Danny Richardson
Subject: Limit Work Types to Specific Classifications or Classstrucureid?
Hello More Maximo Community,
Is it possible to limit a work type to only be available based upon the classification (or classstrucureid) of an asset?
Is this possible natively within Maximo, or would it be possible with an automation script?
Thank you in advance,
#Administration
#Assets
#WorkManagement
------------------------------
Danny Richardson
Maximo Administrator Manager
Technimark LLC
------------------------------