Subscribe method: PSEvent class

Syntax

Subscribe(event_name, callback_method)

Description

Use the Subscribe method to have the PeopleCode program running on the application server subscribe to a notification for an event. Alternatively, JavaScript provides different mechanisms for subscribing to a notification for an event from a PeopleSoft page.

Parameters

Parameter Description

event_name

A string representing the name of the event as defined on the Define Server Side Events page.

callback_method

A string value representing the method to be invoked when the notification is received by the subscriber.

The string must be a fully qualified method name in the form:

APP_PKG:App_Class:Method_Name

Returns

A Boolean value: True if the method completes successfully, False otherwise.

Example

The following example subscribes to a notification named PROCESSSTATUSCHANGE:

&EventObject.Subscribe("PROCESSSTATUSCHANGE", "PT_PRCS:ProcessMonitor:OnProcessStatusChange");

This example requires the implementation of a callback method named OnProcessStatusChange in the PT_PRCS:ProcessMonitor application class:

class ProcessMonitor
	method OnProcessStatusChange(&EventObject As object);
end-class;
method OnProcessStatusChange
  /+ &EventObject as Object +/
  Local string &ID;
	Local string &PROCESSNAME;
	Local string &KEY;

	&KEY = "ID";
	&ID = &EventObject.GetValueOfKey(&KEY);

	&KEY = "PROCESSNAME";
	&PROCESSNAME = &EventObject.GetValueOfKey(&KEY);
end-method;