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.

on March 15, 2022.
Add Comment
1 Answer(s)

This issue is resolved. We used getReferent method and then used  the items attribute and then it went fine.

Agile User Answered on March 16, 2022.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.