Update table event

Is there a way we can trigger an event when a certain column in the table is updated? Currently, the event is triggered when there is an update in any of the columns(Affected Items tab). I want it to be triggered only for one of the columns

No Files Were Attached
Add Comment
2 Answer(s)

The triggering is at the level of update table. Your PX then should check the dirty fields to see if any of them are your column. If not, then exit the PX. Unfortunately, this means if your PX does an update in that table, like setting the revision, then the PX is triggered again. You also might want to filter on whether the trigger event is an Add, Modify or Delete.

Steve Jones, the PLM Doctor Agile Angel Answered on October 1, 2018.
Add Comment

Hi Nikhil,

A simple sample program for your example, here I’ve written a logic to update the new revision cells value automatically by adding 1 to the Old Rev’s value when the New Lifecycle Phase cell of the affected item table is updated. Please keep in mind this is only a sample and a very rudimentary form of code:

public final class UpdateNewRevOnSettingNewLifecyclePhase implements IEventAction {
private static final Logger log = Logger.getLogger(UpdateNewRevOnSettingNewLifecyclePhase.class);
public static IDataObject change;
@Override
public EventActionResult doAction(IAgileSession arg0, INode arg1, IEventInfo arg2) {
IUpdateTableEventInfo info = (IUpdateTableEventInfo)arg2;
String result = “No Change”;
try {
change = info.getDataObject();
IEventDirtyTable table = info.getTable();
IEventDirtyRowUpdate dirtyRow; Integer rowId = new Random().nextInt();
for(Iterator<IEventDirtyRowUpdate> it = table.iterator(); it.hasNext();){
dirtyRow = it.next();
for(IEventDirtyCell cell : dirtyRow.getCells()){
if(cell.getAttribute().equals(change.getAgileClass().getAttribute(ChangeConstants.ATT_AFFECTED_ITEMS_LIFECYCLE_PHASE))){
rowId = dirtyRow.getRowId();
break;
}
}
break;
}
IRow row;
for(Object obj : change.getTable(ChangeConstants.TABLE_AFFECTEDITEMS)){
row = (IRow)obj;
if(row.getRowId().equals(rowId)){
row.setValue(ChangeConstants.ATT_AFFECTED_ITEMS_NEW_REV,
Integer.valueOf(String.valueOf(row.getValue(ChangeConstants.ATT_AFFECTED_ITEMS_OLD_REV)))+1);
result = “Revision successfully set on update of Lifecycle phase”;
break;
}
}

} catch (APIException e) {
log.error(ExceptionUtils.getStackTrace(e), e.getRootCause());
return new EventActionResult(info, new ActionResult(ActionResult.EXCEPTION, e));
}
return new EventActionResult(info, new ActionResult(ActionResult.STRING, result));
}
}

Swagoto Agile Professional Answered on October 1, 2018.
Add Comment

Your Answer

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