Sample Scenario 2: Notification of Changes to an Existing Record - Changing the Credit Limit
You want to create an application event and handler that notifies the credit manager whenever a customer’s credit limit is changed. Because the credit manager prefers email and is not always signed in to the system, you want to send the notification as an email.
You can use an existing framework event, IdoOnItemUpdate, and create our own handler. Because you are simply sending out a notification and the system is not waiting for a response from the credit manager, you can make an asynchronous event handler.
This event handler requires two actions:
- Checks whether the Credit Limit field has been changed
- Sends the email notification
To accomplish this scenario:
-
Create the event handler:
-
Create the first action, which checks the condition of the
Credit Limit field when the
customer record is saved:
-
Create the second action, which sends the email notification:
- To verify that there are no syntax errors, click .
- Discard the cached metadata.
Test this event handler by changing a customer’s credit limit and saving the record. The system generates an email message that gets sent to the credit manager.
In creating this kind of event handler, keep these points in mind:
- To create an event handler that sends an email, you must have the SMTP set up on the Intranets form. Also, the email service on that computer must be set up to enable the relaying of email automatically.
- To have the handler perform an action only when certain conditions are met, use the Finish action type and the CONDITION(NOT PROPERTYMODIFIED) parameter and function.
- To eliminate the single quotes that appear around replacement values in the generated messages, use the PROPERTY function in place of the FILTERPROPERTY function we used in this scenario.