PeopleCode | ‘Hello World’ using the Notification Framework
A. The Pitfalls of PeopleBooks
PeopleBooks is primarily a user manual, which means it aims to be comprehensive and cover every possible field, every possible configuration option, that you have available for any one piece of functionality. This is also its main drawback. As a newcomer to a field, you do not need to know ‘everything’ straightaway. You only need to know enough to develop a basic working example, which is challenging to achieve with PeopleBooks and its mountain-load of information. So with this in mind, we turn our attention to the PeopleSoft Notification Framework, setting up the bare minimum required to get a working example.
Note that the menu paths described below are from Campus Solutions, however similar functionality exists in HR.
B. The Six Steps for Notifications
We can set up a basic notification email by following this six-stage approach. This involves a combination of front-end set-up, along with writing code in App Designer. Note that there is an alternative way to produce notifications that doesn’t involve writing any code. This will considered in a separate tip.
(1) Generic Notification Template
PeopleTooks -> Workflow -> Notifications -> Generic Notification Templates
This is where we can set up the basic template for the email, including any bind variables that we wish to include in the text. For this simple example, we will use one bind variable (%1), that of the employee name.


(2) Notification Setup
Setup SACR -> System Administration -> Utilities -> Notifications -> Notification Setup
Here we perform additional setup required for the email notification. We can edit the template if we wish to, however for this example, we will make no further changes.
On saving this page, make a note of the notification template ID (the field at the top of the page starting with SCC_NTF_TMP). This will be required for later set up.



(3) Consumer Notification Setup
Setup SACR -> System Administration -> Utiliites -> Notifications -> Consumer Notification Setup
Here we specify the App Class to be used for our notification. In this example, we will use a delivered App Class: SCC_COMMON:Notification:BaseParameterProvider
On saving this page, make a note of the notification consumer ID (the field at the top of the page starting with SCC_NTF_CON). This will be required for later set up.

(4) Notification Security
Campus Community -> Personal Information -> Biographical -> Personal Attributes -> Notification Preferences
All Persons in the system (whether employees or students) need to be set up with the relevant preference in order to receive notifications. By default, notifications are NOT enabled. For this example, we will specify that email notifications are enabled.

(5) Generic App Package Class
We now move into App Designer and create a general App Class for the notification. This is usually called ‘NotifyImplement’, or some variant of this. You can copy the code from an existing App Package or use the template below.
The main piece of coding required here is to assign values to the properties (bind variables) of the notification. These could be selected from the database or a page. For this example, we will specify the employee name as a parameter to the notification method. Please refer to lines 18, 112 and 118 below for the specific changes required for the employee name parameter. Note that the Employee ID should always be provided as a mandatory field.
import SCC_COMMON:NOTIFICATION:NotificationManager;
import SCC_COMMON:NOTIFICATION:Accessors:*;
import SCC_COMMON:NOTIFICATION:INotificationContext;
import SCC_COMMON:NOTIFICATION:AbstractNotification;
import SCC_NTF_TESTER:NotificationContext;
import SCC_COMMON:NOTIFICATION:NtfMessageEntry;
import SCC_COMMON:NOTIFICATION:NtfMessageLog;
class NotifyImplement extends SCC_COMMON:NOTIFICATION:AbstractNotification
method NotifyImplement(&p_ConID As string);
method createNtfContext() Returns SCC_COMMON:NOTIFICATION:INotificationContext;
method populateNtfContext(&p_ntfContext As SCC_COMMON:NOTIFICATION:INotificationContext);
method onSuccess();
method onError(&p_Excep As Exception);
property string TEMPLATE_ID;
property string CNTXT_EMPLID;
property string CNTXT_EMPLID_NAME;
end-class;
/******************************************************
Method: NotifyImplement
Description: Constructor
******************************************************/
method NotifyImplement
/+ &p_ConID as String +/
%Super = create SCC_COMMON:NOTIFICATION:AbstractNotification(&p_ConID);
end-method;
/******************************************************
Method: onSuccess
Description:
******************************************************/
method onSuccess
end-method;
/******************************************************
Method: onError
Description:
******************************************************/
method onError
/+ &p_Excep as Exception +/
Local SCC_COMMON:NOTIFICATION:NtfMessageEntry &me;
Local SCC_COMMON:NOTIFICATION:NtfMessageLog &nml;
&nml = %This.ntfMessageLog;
Local string &msg, &entry;
Local integer &i;
If (&nml.isError) Then
For &i = 1 To &nml.length()
&me = &nml.NtfMessageEntries [&i];
If (&me.Severity = 2) Then
Local number &id, &set;
&set = &me.MsgSet;
&id = &me.MsgID;
Local array of string &temp = &me.ParmArray;
If (&temp <> Null) Then
Evaluate &temp.Len
When 0
&entry = MsgGetExplainText(&set, &id, "Message Not Found");
When 1
&entry = MsgGetExplainText(&set, &id, "Message Not Found", &temp [1]);
When 2
&entry = MsgGetExplainText(&set, &id, "Message Not Found", &temp [1], &temp [2]);
When 3
&entry = MsgGetExplainText(&set, &id, "Message Not Found", &temp [1], &temp [2], &temp [3]);
When 4
&entry = MsgGetExplainText(&set, &id, "Message Not Found", &temp [1], &temp [2], &temp [3], &temp [4]);
End-Evaluate;
Else
&entry = MsgGetExplainText(&set, &id, "Message Not Found");
End-If;
End-If;
End-For;
&msg = &entry;
Else
&msg = &p_Excep.ToString();
End-If;
Error &msg;
end-method;
/******************************************************
Method: createNtfContext
Description:
******************************************************/
method createNtfContext
/+ Returns SCC_COMMON:NOTIFICATION:INotificationContext +/
/+ Extends/implements SCC_COMMON:NOTIFICATION:AbstractNotification.createNtfContext +/
Return create SCC_NTF_TESTER:NotificationContext();
end-method;
/******************************************************
Method: populateNtfContext
Description:
******************************************************/
method populateNtfContext
/+ &p_ntfContext as SCC_COMMON:NOTIFICATION:INotificationContext +/
/+ Extends/implements SCC_COMMON:NOTIFICATION:AbstractNotification.populateNtfContext +/
/* Downcast */
Local SCC_NTF_TESTER:NotificationContext &myNtfCntxt = &p_ntfContext As SCC_NTF_TESTER:NotificationContext;
&myNtfCntxt.EMPLID = %This.CNTXT_EMPLID;
&myNtfCntxt.SCC_NTFREQ_TMPLTID = %This.TEMPLATE_ID;
&myNtfCntxt.SCC_NTFREQ_ITMTAG1 = %This.CNTXT_EMPLID_NAME;
/*-----------------------------------------------------
Set Parameters
-----------------------------------------------------*/
/* EmplID Name */
&myNtfCntxt.getParameterMap().Put("%1", &CNTXT_EMPLID_NAME);
end-method;
(6) Call the App Package method
We can now go ahead and call the method created above. For our simple example we will hard-code the employee ID and name into the call.
This code can be added anywhere: on a page, or in an App Engine. Remember to change the name of the App Package (the XXXXX in the example below) to match your own package defined earlier. You will also need to enter your own Consumer ID and Template ID.
After running the code, check your email to see if a notification has been produced.
import XXXXX:NotifyImplement;
/* Define notification */
Local string &sConsumerID = "SCC_NTF_CON_20230730075233";
Local string &sTemplateID = "SCC_NTF_TMP_20230730074715";
Local XXXXX:NotifyImplement ¬ify = create XXXXX:NotifyImplement(&sConsumerID);
/* Send the notification */
¬ify.TEMPLATE_ID = &sTemplateID;
¬ify.CNTXT_EMPLID = "1234567";
¬ify.CNTXT_EMPLID_NAME = "Barefoot";
¬ify.send();
See Also
Tip 058: Creating and Sending Emails