Original Message:
Sent: 05-16-2023 13:12
From: Subhransu Sekhar Sahoo
Subject: Auto Script to make an Object Read-Only
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
Original Message:
Sent: 05-11-2023 09:25
From: Carlos Mestre
Subject: Auto Script to make an Object Read-Only
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
Original Message:
Sent: 05-11-2023 03:59
From: Prashant Sharma
Subject: Auto Script to make an Object Read-Only
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
Original Message:
Sent: 05-10-2023 11:50
From: Carlos Mestre
Subject: Auto Script to make an Object Read-Only
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
------------------------------