Event framework Java PX code example debug,deploy and pop up warning message

Hi All,
I have written event framework java px and I am new in it. I have used “change status  from workflow” event and write following code.Now i have to test it before converted into jar file, So is it possible to test it locally? 
public EventActionResult doAction(IAgileSession session, INode actionNode,
IEventInfo request) {
//IObjectEventInfo objectEventInfo = (IObjectEventInfo) request;
IWFChangeStatusEventInfo objectEventInfo = (IWFChangeStatusEventInfo) request;
IDataObject affectedObject = null;
String changeNo,ActionString = null;
try {
affectedObject = objectEventInfo.getDataObject();
} catch (APIException e) {
// TODO Auto-generated catch block

//def changeno1 = ChangeConstants.ATT_COVER_PAGE_ORIGINATOR;// ChangeConstants.ATT_COVER_PAGE_NUMBER;
try {
changeNo = affectedObject.getName();
IAdmin admin=session.getAdminInstance();
String ChangeNo = affectedObject.getValue(ChangeConstants.ATT_COVER_PAGE_NUMBER).toString();
IChange ChangeObj = (IChange)session.getObject(3 ,ChangeNo);
ITable affectedItemsTable =ChangeObj.getTable(ChangeConstants.TABLE_AFFECTEDITEMS);
Iterator ite = affectedItemsTable.iterator();
while (ite.hasNext())
IRow row = (IRow) ite.next();
String item = row.getValue(ChangeConstants.ATT_AFFECTED_ITEMS_ITEM_NUMBER).toString();
IItem itemObj = (IItem)session.getObject(ItemConstants.CLASS_PART, item);
String ITEMLIFE = itemObj.getValue(ItemConstants.ATT_TITLE_BLOCK_LIFECYCLE_PHASE).toString();
String ItemPartType = itemObj.getValue(ItemConstants.ATT_TITLE_BLOCK_PART_TYPE).toString();
String createUser = “Priyanka Mehta”;
// obj.logMonitor(“item = “+ item +” || ITEMLIFE “+ITEMLIFE+”|| ItemPartType “+ItemPartType);
ITable tab = itemObj.getTable(ItemConstants.TABLE_RELATIONSHIPS);
// obj.logMonitor( ” || item “+item+” || “+ITEMLIFE);
ActionString = ActionString +” “+item+” “;
for (Iterator iterator = tab.iterator(); iterator.hasNext();)
IRow manuRow = (IRow) iterator.next();

String RitemName = manuRow.getValue(ItemConstants.ATT_RELATIONSHIPS_NAME).toString();
String val2 = manuRow.getValue(ItemConstants.ATT_RELATIONSHIPS_CURRENT_STATUS).toString();
// obj.logMonitor( ” || RitemName “+RitemName+” || “+val2);
ActionString = ActionString +” rtm “+RitemName+” “;
if(ITEMLIFE.equals(“Production”) && (!val2.equals(“Production”) ))
ActionString = ActionString +” rtm lc “+ITEMLIFE+” “;
// obj.logMonitor( ” production condtion mismatch”);
String sendToList = affectedObject.getValue(ChangeConstants.ATT_COVER_PAGE_ORIGINATOR).toString();
// affectedObject.sendNotification(“TNMDummyNotifiction”, false, sendToList, “Comments: send from Script handler”);
JOptionPane.showMessageDialog(null, “TNM is not in Production LC state”, “Warning”, JOptionPane.YES_NO_OPTION);
// throw new AgileDSLException(“Item is in production lifecycle and TNM part is not in”);
// obj.logMonitor( ” not enter”);
ActionString = ActionString +” rtm lc not production “+ITEMLIFE+” “;
JOptionPane.showMessageDialog(null, “TNM is not in Production LC state”, “Warning”, JOptionPane.YES_NO_OPTION);
ActionString = ActionString +” not tnm “;


catch (Exception e) {
// throw new AgileDSLException(e);

ActionResult actionResult = new ActionResult(ActionResult.STRING,
return new EventActionResult(request, actionResult);


Now i have following doubts:-
1. I am unable to found how to pass value of IEventInfo.
 I have create void main fx and in it try to used this object like 

try {
factory = AgileSessionFactory.getInstance(“http://secureagiletest.udp.sml.com/Agile/”);

IAgileSession session = factory.createSession(param1);
IDataObject obj1 = (IDataObject)session.getObject(ChangeConstants.CLASS_CHANGE_ORDERS_CLASS , “DCO42921”);
//sm.tnmaction.EventControllerController controller = new sm.tnmaction.EventController();
EventController controller = new EventController();
EventActionResult result = controller.doAction(session, null, (IEventInfo) obj1);

but unable to cast obj1 into Ieventinfo type…

2. I want to show a warning message infront of user so i have written on some condition
JOptionPane.showMessageDialog(null, “TNM is not in Production LC state”, “Warning”, JOptionPane.YES_NO_OPTION);
It will work or not?

3.how and where to add jar files so that my class name will appears on LOV in java client event management–>event handlers–>event action

No Files Were Attached
priyanka Agile User Asked on August 20, 2018 in Other APIs.
Add Comment
1 Answer(s)

Hi Priyanka,

You can take basically take most of what you have and test it as a Groovy PX just fine – just the main method and return method will be different on a groovy PX.  I’ve done that to test chunks of script at a time and basically anything written in Java will convert over to Groovy just fine.  You can try exporting as a jar and testing in your test environment as well.  I’ve never got a JOptionPane to work in Groovy script though I’ve never tried on a java PX (can anyone else confirm?).  

Your script looks ok to me.  I noticed that you’re getting the IChange/Dataobject twice in your script.  Replace line 5 (IDataObject affectedObject = null;) to (IChange affectedObject = null) and you won’t need lines 17 and 18.  Your line <String ITEMLIFE = itemObj.getValue(…> might want to be switched to the row.getValue(ChangeConstants.ATT_AFFECTED_ITEMS_LIFECYCLE_PHASE) just to be on the safe side.  Also try IItem itemObj = row.getReferent() as an easy way to get the IItem dataobject on a Change Order affected items table.  

I can’t really say why you’re not able to get the IEventInfo object info but that’s because I’m way more familiar with how Groovy scripts handle this.  I am confident that your casting issue is because you need to change it to an IChange object instead (IChange obj1 = (IChange) session….).

Check out Oracle Doc ID 760058.1, Doc ID 885594.1, and Doc ID 742488.1 for more help and step by step guides for deploying Java PXs.

Matt Paulhus Agile Angel Answered on August 20, 2018.
Add Comment

Your Answer

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