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

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.

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));
}
}

Agile Expert Answered on October 1, 2018.

Hi,
is it possible to get action info of event fired means in IUpdateTableInfo there is changes for row update or file add/deletion.
When rowupdate is done then we should cast dirty table iterator to IEventDirtyRowUpdate. if i cast it to IEventDirtyRowFileUpdate then it raised exception.
So is it possible to get table row info before getting row iterator?
In my case user can update table or add new row in table, on the bases of user action i will execute specific condition for both case.

      
  IEventDirtyTable DTbl=objectEventInfo.getTable();      
            Iterator it=DTbl.iterator();
            while(it.hasNext()){               
                IEventDirtyRowUpdate  row=(IEventDirtyRowUpdate) it.next();
}

on April 9, 2019.
Add Comment

Your Answer

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