Maximo Open Forum

 View Only
  • 1.  Auto Script to make an Object Read-Only

    Posted 05-10-2023 11:50

    Hi All, 

    At my organization, we have created attribute THD_INTEXT on the WORKORDER object. I am trying to create an auto script that makes the WPSERVICE object readonly when the THD_INTEXT = 'INTERNAL'. This auto script has a Launch Point on the WPSERVICE object, and it's running on the "Initialize value" event. See my code below:

    "from psdi.mbo import MboConstants

    # Get the related Work Order object
    workorder = mbo.getMboSet("WORKORDER").getMbo(0)

    # Check if the THD_INTEXT attribute of the Work Order is 'INTERNAL'
    if workorder.getString("THD_INTEXT") == 'INTERNAL': //ERROR
        # If so, set the WPService object as read-only
        mbo.setFieldFlag(MboConstants.READONLY, True)"

    I keep getting this error "AttributeError: 'NoneType' object has no attribute 'getString' in <script> at line number 7". I have checked database configuration, and THD_INTEXT is an attribute of the WORKORDER Object. Could someone help me understand why I am getting this error?


    #MaximoApplicationSuite

    ------------------------------
    Carlos Mestre
    Home Depot
    ------------------------------


  • 2.  RE: Auto Script to make an Object Read-Only

    Posted 05-11-2023 04:00

    Hello 
    May be because 

    workorder = mbo.getMboSet("WORKORDER").getMbo(0)  is returning NULL

    also mbo.setFieldFlag will not make whole object Read only. SetFieldFalg will make only specific field read only.

    Why are you writing automation script for this requriement and that too at init() which will hamper system performance, You can achieve this requirement with Condition Expression and Security Group Data Restriction or with App Designer Conditional Properties.



    ------------------------------
    Prashant Sharma
    Sedin Technologies
    Connect with me @ https://www.linkedin.com/in/psharmamaximo/

    #IBM Champion 2022
    #IBM Champion 2023
    ------------------------------



  • 3.  RE: Auto Script to make an Object Read-Only

    Posted 05-11-2023 09:25

    Hi Prashant, 

    Could you please explain why this script would hamper system performance? I attempted to set an object restriction on a security group on WPSERVICE to make it read-only. My condition is the following:

    exists (select 1 from workorder where wonum = :wonum and thd_intext = 'INTERNAL')

    This is making WPSERVICE readonly when the THD_INTEXT equals Internal or External. I only want WPSERVICE to be readonly when THD_INTEXT equals Internal.



    ------------------------------
    Carlos Mestre
    Home Depot
    ------------------------------



  • 4.  RE: Auto Script to make an Object Read-Only

    Posted 05-16-2023 13:12

    Hi Carlos, 

    Any script in object's init will be invoked each time when the object gets loaded into Memory. so the script will start occupying unnecessary spaces in memory as well. So mostly we avoid writing script in the initialise event (except the NP mbo cases) of MBO unless we didn't find some other flexible way to implement it. 

    What Prashant mentioned is correct. if something is achieved through configurations , there is no need to write a script on Object's initialization. 



    ------------------------------
    Subhransu Sekhar Sahoo
    Tata Consultancy Services
    ------------------------------



  • 5.  RE: Auto Script to make an Object Read-Only

    Posted 05-17-2023 09:42

    Hi Subhransu, 

    Thank you for your reply. I tried to set an Object Restriction on a Security Group on WPSERVICE. My condition is the following:

    exists (select 1 from workorder where wonum = :wonum and thd_intext = 'INTERNAL')

    This is making WPSERVICE readonly when the THD_INTEXT equals Internal or External. I only want WPSERVICE to be readonly when THD_INTEXT equals Internal. Any idea why this condition is not working? Any help would be greatly appreciated!



    ------------------------------
    Carlos Mestre
    Home Depot
    ------------------------------



  • 6.  RE: Auto Script to make an Object Read-Only

    Posted 05-17-2023 12:38

    Prashant and Subhransu are correct to highlight the around using the init method.

    I want to expand on this comment. 
    "Any script in object's init will be invoked each time when the object gets loaded into Memory. " - This will trigger WHENEVER the WPSERVICE object is loaded into memory e.g. if it gets loaded into memory as part of an integration operation or via the front-end.

    It would trigger when viewing a workorder that is in history. In this case that isn't a problem but it is something to know particularly if the script is then adapted to set a value.
    If the script did try and set the value then the MBO couldn't be loaded into memory and the user would receive a blank Workorder record when they try and view a historic workorder in Work order tracking.

    It is always worth monitoring the logs to see if MBOs are being kept in memory longer than you expect.

    If you aren't familiar with the process of checking these then I discuss it in this blog article.
    https://www.linkedin.com/pulse/seeing-which-mbosetsmbos-using-memory-mark-robbins/



    ------------------------------
    mark robbins
    Cohesive
    IBM Champion 2017-2023 Inclusive
    See my blog on Maximo support related topics here:
    https://www.linkedin.com/pulse/maximo-support-advice-from-non-ibm-engineer-article-mark-robbins/
    ------------------------------