About the MakeResponseMessage Subroutine

The MakeResponseMessage subroutine is called only from the Folder_OnMessageCreated subroutine. MakeResponseMessage provides most of the functionality in Folder_OnMessageCreated, by processing forms posted to the folder.

The MakeResponseMessage subroutine first calls GetPropertiesFromLitCrit, which saves the values of fields in the posted message into local variables. Among the variables from the form that are used for branching to the proper logic are ApprovalRequired, IsApproved, and CritiqueNo (see CritiqueNo Travels with the Critique).

Processing Critiques Returned From Administrators

After retrieving these values from the posted form, MakeResponseMessage checks the CritiqueNo. If it is nonzero, the form has been sent — either approved or rejected — from the administrator. In this case, if the form was rejected, it is deleted from the FmLib database and from the public folder:

objCritique.DeleteRecordByCritiqueNo CritiqueNo
msgTarget.Delete ' triggers the delete event

If the critique was approved (IsApproved=1), its record in the FmLib database is updated with any new values it may have. This occurs with a call to the Critique COM component:

objCritique.UpdateRecord CritiqueNo, NewMessageID, True

Processing Newly Posted Critiques

If the form's CritiqueNo is equal to zero, it is a new posting, and its bibNo is checked. This number identifies it uniquely in the FmLib database. If bibNo is equal to zero, the title being reviewed is either not present in the FmLib database, or the user chose not to check for its presence in the database. Items in this category are not subject to approval, and the form is saved to the public folder — but not, of course, to the FmLib database.

If the bibNo is nonzero, a title in the FmLib library is the subject of the critique. The next value checked is that of BorrowerNo, which uniquely identifies a library user. The BorrowerNo is retrieved by calling the BorrowerInfo method of the Critique object. This method calls the User component of the CML application which in turn calls GetInfoFromExchange, and if necessary UpdateInfoFromExchange, to retrieve an existing (or create a new) BorrowerNo.

The ultimate purpose here is to determine whether the person has a valid logon name in the borrower table of the FmLib database. This is because a person needs a BorrowerNo in order to add a record to the Critique table, which has a foreign key relationship with the borrower table in the FmLib database.

If the returned BorrowerNo is nonzero, the person's name has been resolved in the Microsoft Exchange Server directory, so a record for the critique can be added to the FmLib database. This occurs with a call to the AddRecord method of the Critique object:

CritiqueNo = objCritique.AddRecord(bibNo,borrowerNo,CritiqueTitle, _
                   NewMessageID,Rating,CDate(dateOfCritique), _
                   IsApproved)  

After that, if administrator approval is required for this critique, MakeResponseMessage calls CopyToApprover and then SendApproverForm; it then deletes the original critique after its copy is sent. If approval of the critique is not required, the critique is simply written to the public folder (its record has already been updated in the FmLib database).

If administrator approval is not required (ApprovalRequired = 0) the ToApprover form need not be created. But certain pieces of information still need to be updated, such as OldUserName, which is used when the critique is later opened, to decide which page to display. If the current reader and the original submitter (OldUserName) are the same person, the HalfRead form is shown, but if they are different people, the Others form is shown. Also, the CritiqueNo, saved at this time, will later tell that this is an old critique, not a newly posted one.

CritiqueNo Travels with the Critique

CritiqueNo is a unique number generated automatically by the Critique table in the FmLib database. The field on the EnhancedLitCrit form that holds the CritiqueNo is empty at first because CritiqueNo is unset until the critique is posted and processed.

After posting, the Event Service agent communicates with the FmLib database through the server-side Critique COM component, which adds a record for the critique and obtains the new CritiqueNo. This value is then passed to the ToApprover form. After the form is sent to an approver and returned, the CritiqueNo is copied back onto a new EnhancedLitCrit form, which, when posted to the public folder, triggers another Folder_OnMessageCreated event.