Sunday 24 September 2017

Enforce Unique Key & Fetch Records From Unsaved MBO Using Automation Script | IBM Maximo


This automation scripts describes the enforcing of unique key to the object, Fetching and looping through unsaved rows of MBO Set from memory.
We have taken the example of restricting the users from selecting same itemnum multiple times in spare parts of asset. It works on both saved and unsaved objects.

Launch Point: Attribute Lauch Point
Business object:  SPAREPART
Attribute: ITEMNUM
Variable: ar_item bind with ITEMNUM of object SPAREPART

owner= mbo.getOwner();
if owner and owner.getRecordMboName()=="ASSET":
   issueitemMbo=owner.getMboSet("SPAREPART");
   LinesCount = issueitemMbo.count();
   Line1=[ ];
for i in range(LinesCount):
   Line= issueitemMbo.getMbo(i);
   Line1.append(Line.getString("ITEMNUM"));
   Line2= ar_item;
   if  LinesCount > 1:
          if Line2 in Line1[i-1]:
    errorgroup = 'asset'
    errorkey = 'sparepart'

  1. Go To Assets Application. 
  2. Select spare part item on 'Spare Parts Tab'. 
  3. Add item in spare parts tab and then try to select same item without saving. It works for both on saved and unsaved objects.
  4. If the spare part item already exits for that asset. It gives the error mentioned in below screenshot.





No comments:

Post a Comment