AddRecord Method

The AddRecord method is a public function in the Critique component that adds a record to the Critique table of the FmLib SQL Server™ database and retrieves the primary key (critique#) of the inserted record. The critique# is returned to the CML/LitCrit server-side script where it is copied to a property on the LitCrit Outlook® form and used to link the LitCrit critique with a record in the FmLib Critique table.

The method accepts eight parameters:

Two variables are declared:

The following code fragment shows how values are copied to the varFields and varValues variables.

varFields = Array("bib#", "borrower#", "title", "objectID", "rating", "dateOfCritique", "isApproved")
varValues = Array(BibNo, BorrowerNo, CritiqueTitle, MessageID, Rating, CStr(DateOfCritique), IIf(IsApproved, 1, 0))

The critique record is added using the AddNew method of the ADODB recordset object named oRs, and the Resync method of the ADODB object refreshes oRs from the FmLib database and provides the critique# (the primary key of the Critique table) for the inserted record. The function returns the critique#.

oRs.AddNew varFields, varValues
oRs.Resync
AddRecord = oRs("Critique#").Value

The Critique component is instantiated in the server-side script that runs when the Folder_OnMessageCreated event fires on LitCrit, the public folder in which the critiques are posted. The script then makes a call to the AddRecord method in the Critique component.

The complete code for the AddRecord method is available in Critique.cls Server-Side COM Component in the code section.