Create a non-persistent field with an automation script

When you create a non-persistent field in Maximo, normally you would create a custom java class behind that field.  But with automation scripts, you can create an NP field and populate it with data when you initialize it.  In this example, we will create an NP field to get the count of how many times the current user has requested materials.

First, go to DB configuration and add a new field named REQUESTCOUNT and be sure to uncheck the “Persistent?” field checkbox.

Save it and apply configuration changes.

Next, go to Automation Scripts and create a new attribute launch point for the REQUESTCOUNT field.  You need to set the event to “Initialize Value”.

Then add this jython code:

from psdi.util import MXApplicationException
from psdi.mbo import MboConstants
from psdi.mbo import SqlFormat
from psdi.server import MXServer
from java.util import Calendar
from java.util import Date

################################# 
# Helper function to get any MboSet
################################# 
def getMboSet(objectName): 
  return MXServer.getMXServer().getMboSet(objectName, mbo.getUserInfo()) 
 
################################# 
# Script code begins here 
#################################
matReqSet = getMboSet("MATREQLINE") 
matReqSet.setWhere("ITEMNUM = '" + mbo.getString("ITEMNUM") + "' AND MATREQNUM IN (SELECT MATREQNUM FROM MATREQ WHERE REQUESTBY = '" + mbo.getUserInfo().getUserName() + "')")
matReqSet.reset()

mbo.setValue("REQUESTCOUNT", matReqSet.count(), MboConstants.NOACCESSCHECK)

Now the REQUESTCOUNT field will show the count whatever you need it to show.

In Maximo 7.6, there is a new feature called Maximo Formulas… which is another way to create NP fields without an Automation script but still do complicated calculations for a field….

Did You Know...

As Maximo Experts, we have developed several add-on products for Maximo that mobilize the work force, simplifies assignments, provides ad-hoc reporting capabilities and facilitates the seamless integration of Service Requests into Maximo.

Check out our products by clicking on the following links: EZMaxMobile, EZMaxPlanner and EZMaxRequest.

Find Out More

2 thoughts on “Create a non-persistent field with an automation script

  1. hy chon . please guide. i want to ristrict pr for example user entered second line on pr of same item on same pr then system should give message you can not 2nd line of same item .??

  2. hy chon . please guide. i want to ristrict pr for example user entered second line on pr of same item on same pr then system should give message you can not enter 2nd line of same item .??

Leave a Reply