Sample Scenario 3: Notification that includes an Old Value
You want to notify a group of inventory stock clerks automatically whenever an item’s lot size changes. In the message that is sent, you want to include both the previous lot size and the new lot size. You also want to let them know who initiated the change.
You can use an existing framework event, IdoOnItemUpdate, and create a handler for this application event. Because this handler needs to retrieve the before property values, you must make this synchronous, so that during handler execution you can retrieve from the database the original row that is being updated, before it is updated by the IDO request.
This event handler requires three actions:
- Checks whether the Lot Size field has been changed and, if not, finish
- Retrieves the row that is being updated and both the original and new values for the Lot Size field
- Sends the notification to the inventory stock clerks
To accomplish this scenario:
Test this event handler by using the Items form and locating an item that is lot-tracked. On the General tab, you can change the value in the Lot Size field. In the stockers’ Inbox forms, verify that the message is sent and contains the correct values.
In creating this kind of event handler, keep these points in mind:
- To retrieve the existing value of a field for display in a message, you must make the handler synchronous.
- To display both the original value of a field and the new one, use an event variable to temporarily store the original value.
- Substituted values in a statement can be presented in any order as long as their index numbers match their positions in the list.
- To prevent single quotes from being placed around a substituted value, use the PROPERTY function instead of the FILTERPROPERTY function.
Try to add an item description to the body of the message. This may require you to determine the name of the item description property.