Event PX using groovy script for validating a particular item in BOM item
Hi
Have a requirement where will have to check for BOM item part type and if it is of a particular type only compared to the parent item, BOM item should be allowed to be added.
How to achieve this using groovy.
When tried , parttype,itemno etc is giving null, even though it goes inside the DIRTY_ROW_ACTION_ADD condition and prints “Within add action”
Pasting a snippet of the code.
Using PRE trigger for event subscriber.
void invokeScript(IBaseScriptObj obj) {
//script body starts here.
IAgileSession session = obj.getAgileSDKSession();
IAdmin admin = session.getAdminInstance();
IEventInfo req = obj.getPXEventInfo();
IUpdateTableEventInfo eventInfo = (IUpdateTableEventInfo)req;
IDataObject item = eventInfo.getDataObject();
//IEventDirtyCell[] cells = eventInfo.getCells();
IEventDirtyTable dirtyTable = (IEventDirtyTable)eventInfo.getTable();
Iterator it1 = dirtyTable.iterator();
itemsubclass = item.getValue(1081).toString();
obj.logMonitor(“item subclass:” + itemsubclass);
try {
while (it1.hasNext()) {
IEventDirtyRowUpdate row = (IEventDirtyRowUpdate) it1.next();
int rowAction = row.getAction();
if (rowAction == EventConstants.DIRTY_ROW_ACTION_ADD) {
obj.logMonitor(“Within add action”);
String itemno;
itemno = row.getCell(1011);
obj.logMonitor(“Item no ” + itemno);
parttype = row.getCell(3582).toString();
obj.logMonitor(“Part Type is ” + parttype);
}
Thanks in advance
Sabarish
This issue is resolved. We used getReferent method and then used the items attribute and then it went fine.
Sabarish
This issue is resolved. We used getReferent method and then used the items attribute and then it went fine.