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'
- Go To Assets Application.
- Select spare part item on 'Spare Parts Tab'.
- Add item in spare parts tab and then try to select same item without saving. It works for both on saved and unsaved objects.
- If the spare part item already exits for that asset. It gives the error mentioned in below screenshot.
No comments:
Post a Comment