This tutorial shows you how to create a template record and how to load a template record.
A template record contains default data values. You can use a template record when you create a record to add to the Comms Database.
For example, the records in
the DialOutISP table
are large. Many of the fields in a DialOutISP
record have
values that are the same in all DialOutISP
records. A template
record can contain these common values. When you create a DialOutISP
record,
set the value of those fields to be copied from the template record to NULL.
Set the other fields in your DialOutISP
record to values
that are specific to that record.
These principles apply to all record types.
The following steps create and load a template record for the Network table.
Before you start, you must understand:
Make sure that you have created a session.
Set the attribute mask for this session to hidden.
Template records are marked as hidden. Set the session mask to hidden to allow you to view the template records.Example:
cmdbSession->SetAttributeMask(ECDHidden);
Create a template record and store it in the database.
Example:
... // Create a "Network" record, but give it the unique numeric Id KCDDefaultRecord. // The CommsDat API interprets the record Id KCDDefaultRecord to mean the // template record. CCDNetworkRecord* ptrNetworkRecord = (CCDNetworkRecord*)CCDRecordBase::RecordFactoryL(KCDTIdNetworkRecord); ptrNetworkRecord->SetRecordId(KCDDefaultRecord); // Template records must be hidden. ptrNetworkRecord->SetAttributes(ECDHidden); // Store the template record in the database ptrNetworkRecord->StoreL(*cmdbSession); ...
Load the template record from the Comms Database
Example:
... // Create an empty "Network" record, and set the record Id to KCDDefaultRecord // The CommsDat API interprets the record Id KCDDefaultRecord to mean the // template record. CCDNetworkRecord* ptrNetworkRecord = (CCDNetworkRecord*)CCDRecordBase::RecordFactoryL(KCDTIdNetworkRecord); ptrNetworkRecord->SetRecordId(KCDDefaultRecord); ptrNetworkRecord->LoadL(*cmdbSession); ...