Stored Procedure TP_SubDocAdd
Overview
Tired of creating procedures that do the exact same thing with the exception of a single table name? Seeking an easier way to add subdocuments from the Console? There is a solution that!
Details
The stored procedure, TP_SubDocAdd could be your solution. This procedure calls the TP_CreateNewTierDocumentID procedure to generate a new document in T4W_Documents. Then, it uses dynamic SQL to create the code that inserts the data into the appropriate FD table and Master table linked to the form. You can add a single button to a console and connect it to the TP_SubDocAdd stored procedure in order to create documents.
Parameters used for the stored procedure are described in the following table.
| Parameter (datatype) | Description |
|---|---|
| TierUserID (int) | The ID of the user who is logged into TIER |
| TierFormID (int) | The OP ID of the form\document creating (from T4W_Forms) |
| ClientKey (int) |
The ID of the client the document is being created for (OP DOCID from FD Clients) |
| AdmissionKey (int) |
The ID of the client’s admission the document is being created for (OP DOCID from FD Agency_Admission) |
| PgmKey (int) |
The ID of the client’s program the document is being created for (PGMKEY from FD Program_Client) |
| PgmAdmissionKey (int) |
The ID of the client’s program admission the document is being created for (>OP DOCID from FD Program_Client) |
| DocType (varchar 120) |
The type of document being created. Determines if the data needs to write to any Master tables. N - Note writes to FD__MasterNote A - Assessment writes to FD__Master_Assessment |
Since this procedure uses dynamic SQL, each form must have key columns specified in order for the procedure to work. To set up the key columns for a form, use a Facesheet Console Setup form in TIER.

