You can update existing process notification instances at runtime by changing their processing time and status.
The processing time is represented by a deadline, which can be an exact date set in time, or duration related to some starting point (action or process start). For more information, see Creating Deadlines and Durations.
● You have set up your project in SAP NetWeaver Developer Studio.
For more information, see Setting Up Your Project.
● You know how to create deadlines and durations.
For more information, see Creating Deadlines and Durations.
...
1. Retrieve a notification instance defined for a process:
import com.sap.caf.eu.gp.process.rt.notification.api.IGPNotificationInstance; import java.util.Enumeration;
// get all notification instances of a process Enumeration notifications = process.getNotificationInstanceEnumeration();
// retrieve a single notification instance IGPNotificationInstance notification = null; while (notifications.hasMoreElements()) { notification = (IGPNotificationInstance) notifications.nextElement(); } |
For more information, see Retrieving Process Notification Instances.
2. Retrieve relevant information about the instance.
Depending on the update operation you want to perform, you may need to know certain notification instance attributes in advance, for example, notification ID, process ID, whether it is a due date notification, and so on.
import com.sap.caf.eu.gp.process.api.IGPDeadline;
//get relevant attribute information, for example: String processInstanceID = notification.getProcessInstanceID(); String notifID = notification.getNotificationID(); boolean dueDate = notification.isDueDateNotification(); long createDate = notification.getCreationDate(); IGPDeadline deadline = notification.getDeadline(); ...
|
3. Change the status of the notification instance.
You are able to change the status of a notification instance only if it is not processed yet, that is, its status is set to NOTIFICATION_STATUS_WAITING. If the notification has been already executed or cancelled, this change is impossible.
You can choose from the following notification statuses:
○ NOTIFICATION_STATUS_DEPRECATED – notification is deprecated, a more up-to-date version exists
○ NOTIFICATION_STATUS_EXECUTED – notification is executed
○ NOTIFICATION_STATUS_CANCELLED – the activity was completed before the time of notification processing
○ NOTIFICATION_STATUS_ERROR – an error occurred during the processing of the notification
// update the status – cancel the notification notifManager.updateNotificationStatus( processInstanceID, activityID, notifID, IGPNotificationInstance.NOTIFICATION_STATUS_CANCELLED ); |
4. Update the processing time of the notification instance.
This operation automatically creates a new version of the notification. The status of the old version is set to deprecated (NOTIFICATION_STATUS_DEPRECATED). Both versions are stored in the notification history.
import com.sap.caf.eu.gp.process.rt.api.IGPNotificationManager;
// update the notification instance with a new deadline notifManager.updateNotification( processInstanceID, activityID, notifID, deadline ); |