beautypg.com

Kofax DOKuStar Validation User Manual

Page 26

background image

DOKuStar Validation Programming Manual

Page

22

Let us look at the code in detail: We now added a subroutine

FillData

that gets the

data

object of the

DataSet

as input.

One document is then added:

'* add a document
Set doc = MyData.Documents.Add("Letter")
doc.Fields("Sender").Value = "Océ Document Technologies"
Set subdoc = doc.Documents.Add("CoveringLetter")
Set subdoc = doc.Documents.Add("Invoice")
subdoc.Fields("TotalAmount").Value = "100.00"

The data object has a

Documents

collection with an

Add

method, through which you add documents. The

method can take a document type name as a parameter (as above) or a

DocumentType

object. Of course, this

document type name must be defined in the

Schema

part of the

DataSet

, else an error will be reported.

The

Add

method delivers a

Document

object . This object has a

Fields

collection assigned to it, which holds

the collection of fields defined for the corresponding document type. The list of fields is known from the

Schema

,

so they are all defined (but empty) as soon as you create the

Document

object. So, you don’t add fields to the

document, but reference them, as it is done in the statement

doc.Fields(„Sender“)

above. The index into

the

Fields

collection again is the field name. This delivers a

Field

object, which has (among others) a

Value

property, which is set to the desired contents.

The

Document

object also has got a

Documents

collection, which holds the list of subdocuments (which again

are

Document

objects). Accordingly, we add the subdocuments of

Letter

and set the values.

Note: When you define subdocuments of a document in the schema part, these subdocuments are optional. The
individual subdocuments need not appear in the documents, or they may also appear more than once.