Setting multiple fields as readonly with script

Sometimes you may need to allow some users to update only few fields. This may be hard to achieve using conditional UI and conditional expressions.

In the following snippet I’m setting all fields as readonly except DESCRIPTION and STATUS if the current user is in MANSUP security group. Attach the script to the Initialize event of the object you want to control.

from psdi.mbo import MboConstants
from psdi.server import MXServer

# check if the current user is in MANSUP security group
currentuser = mbo.getUserInfo().getUserName()
groupuserSet= MXServer.getMXServer().getMboSet('GROUPUSER', mbo.getUserInfo())
groupuserSet.setWhere("groupname in ('MANSUP') and userid='" + currentuser + "'")

if not groupuserSet.isEmpty():
    mbo.setFieldFlag(["DESCRIPTION", "STATUS"], False, MboConstants.READONLY, True)

The powerful trick here is to use the method Mbo.setFieldFlag(names, inclusive, flag, state)

Passing False to the inclusive flag will tell Maximo to set all other fields readonly.

Setting multiple fields as readonly with script

Leave a Reply

Your email address will not be published.


Scroll to top