Sample scenario 1: Notification of a new record - Adding a user
Suppose you have a system administrator who wants to be notified whenever a new user is added to the system, regardless of who adds the user. You could simply require each employee who adds users to the system to manually send a notice whenever a user is added. But that places an additional burden on the employees and is prone to possible oversight.
You can use the Application Event System to automatically create a notice whenever a new user is added. In this example, you do not need to create an application event, because Infor provides an application event, named IdoPostItemInsert, that you can use. All you need to do is create an event handler for that application event and assign an action that generates and sends the message to the system administrator.
Actually, we could use the IdoOnItemInsert framework event instead of the IdoPostItemInsert event. This is significant in refining the message. The advantage of using the IdoPostItemInsert event is that, if you allow the Users form to auto-assign the user ID number, instead of specifying the user ID number yourself, the system waits until the ID number has been assigned before filling in the CustNum data in the message. If you use the IdoOnItemInsert event, the system does not wait, which means that, if you auto-assign the customer ID number, the resulting message has TBD in place of the actual customer number.
Test the application event by using the Customers form to create a new customer. Then, sign in as the user ID that specified in the TO parameter, open the Inbox form, and verify that the message was received. The message must appear there, along with the properties associated with the new customer, on the Variables tab. Note that, because you did not specify any variable access rules, all properties (variable values) are display-only.
In creating this kind of event handler, keep these points in mind:
- If you do not require a response from the recipient, create the handler as an asynchronous handler, to avoid system slow-downs.
- To be able to use a recipient in other handlers and be able to change that recipient when necessary in only one place, use an event global constant for the recipient.
- To use active data in a message, use the SUBSTITUTE and PROPERTY (or P) function constructs.