Sample Scenario 1: Notification of a New Record - Adding a User

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 can 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 employee 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 that is 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.

We can 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.

To set this up:

  1. Create the event handler:
    1. Open the Event Handlers form.
    2. Press F3.
    3. Press Ctrl + N.
    4. Create the handler with these settings:
      Event Name
      Select IdoPostItemInsert.
      Applies to Initiators
      Leave this field blank.
      Applies to Objects
      Specify SLCustomers.
      Keep With
      Leave this field blank.
      Chronology
      Leave this field blank.
      Initial State
      Leave this field blank.
      Initial Action
      Leave this field blank.
      Active
      Select this check box.
      Can Override
      Select this check box.
      Ignore Failure
      Clear this check box.
      Suspend
      Clear this check box.
      Obsolete
      Clear this check box.
      Synchronous
      Clear this check box.
      Note: Because this notification does not require any response from the credit manager, it can run asynchronously.
      Transactional
      Clear this check box.
    5. Click Save.
  2. Define the action for the event handler you just created:
    1. On the Event Handlers form, select the handler you created in Step 1.
    2. Click Event Actions.
    3. On the Event Actions form, specify this information:
      Action Sequence
      Specify 10.
      Note: Technically, you can specify any integer you want in this field and the system treats them sequential order. We recommend using multiples of ten, initially at least, in case you later need to add more action steps between existing steps, so you do not need to renumber all existing steps.
      Action Type
      Select Notify.
    4. Click Edit Parameters.
    5. On the Event Action Notify form, click the To button.
    6. On the Event Action Parameter Recipients form, from the list of recipients, select the user ID of the credit manager or whoever is serving in that role.
      Note: You can select more than one recipient. Also, to deselect a recipient, click the user ID again.
    7. Click Update and then OK.
    8. On the Event Action Notify form, specify this information:
      Subject
      Specify New Customer!.
      Save in Sent Items
      Select this check box.
      Note: This parameter tells the system to save a copy of the notification in the Sent Items folder of the person who added the new customer.
      Body
      Specify We have a new customer!.
      Category
      Specify Change Notification.
    9. Click OK.
    On the Event Actions form, in the editable field on the Parameters tab, you should see this:
    CATEGORY("Change Notification")
    TO("userID")
    SUBJECT("New Customer!")
    BODY("We have a new customer!")
    SAVEMESSAGE(TRUE)

    where userID is the sign-in user ID for the credit manager.

    Note: Note where double quotation marks and parentheses are inserted. Because it can be confusing to know where and when to use these punctuation marks, we recommend that you use the event action parameter forms as described in these scenarios. They insert the correct punctuation marks automatically where and when needed and can help you avoid many time-consuming errors in syntax.
  3. Optionally, click Check Syntax to verify that there are no syntax errors.
  4. Save the action and close the Event Actions form.
  5. Discard the cached metadata.

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.