How can we send notifications to user upon deleting Program object?

How can we send notifications to user upon deleting Program object? We cant subscribe a notification to a delete object event. Can you share the process how can we do this? any sample code

Add Comment
1 Answer(s)
Best answer

Hi,

You can use the Delete Event to trigger a custom EventPX.

In your JAVA script you can cast the event to IDeleteEventInfo in order to have the following methods that can help you to create a custom notification

String  getNumber () throws APIException
Integer  getSubclassId () throws APIException
boolean  isSoftDeleteAction () throws APIExceptio

Agile Angel Answered on April 12, 2016.

Can you please elaborate. I’m novice to agile plm sdk. Have little knowledge in java. Please share me more info to anvesh2626@gmail.com

on April 12, 2016.

Hi Anvesh,

please find below a simple code to send a custom notification using EventPX and AgileSDK

public class DeleteNotifyPX implements IEventAction {
 @Override
 public EventActionResult doAction(IAgileSession session, INode node, IEventInfo event) {
 try {
 IDeleteEventInfo deleteEvent = (IDeleteEventInfo) event;
 String number = deleteEvent.getNumber();
 IUser user1 = (IUser) session.getObject(IUser.OBJECT_TYPE, "userId1");
 IUser user2 = (IUser) session.getObject(IUser.OBJECT_TYPE, "userId2");
 IUser[] usersToBeNotified = new IUser[]{user1,user2};
 session.sendMail(usersToBeNotified, "The Object "+number+" has been deleted");
 return new EventActionResult(event, new ActionResult(ActionResult.STRING, "Notification sent"));
 } catch (Exception e) {
 return new EventActionResult(event,new ActionResult(ActionResult.EXCEPTION, e)); 
 }
 }
}

userid1 and userid2 are the login id of users that you want to notify when an object is deleted.

You can deploy the code as Process Extension (http://docs.oracle.com/cd/E28664_19/otn/pdf/integration/E28698_02.pdf) and 
configure this PX as EventPX in the java client (http://docs.oracle.com/cd/E28664_19/otn/pdf/administration/E28674_01.pdf)

on April 13, 2016.

Thanks a lot !! By the way can we do it in script px?

on April 13, 2016.

Yes, You can write the groovy script. But same code doesn’t work. you need to change little bit.

on April 20, 2016.
Add Comment

Your Answer

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