Application Scenario: an Expense Report

A typical and appropriate use of server-event scripting is an approval application such as expense-report processing. In this example, a person wanting reimbursement fills out and submits a request in the form of an e-mail message. The simplest routing path takes the message to the requester's supervisor, to a person in Accounts Payable, and finally back to the requester, with payment notification.

This example shows that scripts can use information from a message, obtain information from other sources, and respond accordingly, which may include changing the path the message takes.

The employee submits an expense report by mailing or posting it to a designated "Expense Report" folder. Its arrival in the folder (known as the "application" folder) triggers the Folder_OnMessageCreated event.

The Folder_OnMessageCreated subroutine in the script evaluates the properties contained in the expense report and verifies that all the required ones are present. If any are missing, it returns the report to the sender.

This subroutine also evaluates the amount requested in the expense report. It can look up the name of the sender's manager in the directory and forward the report to that person automatically. Or it can look up the expense authorization budget limit and forward the report to the manager's manager if the limit would be exceeded. In this way, the subroutine can use server-side logic to perform directory lookups and make routing decisions based on properties of people in the directory.

If we assume that expense reports will not be edited while being processed, the script that processes them will not need a Message_OnChanged subroutine. But it would almost certainly need a Folder_OnTimer subroutine, which would be triggered if no response has arrived from the manager who received the request after a chosen number of days. The subroutine could, for example, notify the requester (or the manager's manager) of the delay and suggest that another action be taken.