Description

The class DocExt is the main public class of the library DocExtLib. An object of the class is indissolubly related to a document of an app. Just give the document when you are creating DocExt object. An object of the class is working with the config document of DocExt type named as the form of the document which the object is related to.


Object creating

You need create a DocExt object before the document will be changed. Thus for a UI document changing by a user through its form you should type the DocExt object's creating in the event PostOpen of a form. For a back-end document type the DocExt object's creating for it before all changes of the document in a code.

The object dimension:

dim doc as NotesDocument

dim ext as DocExt

The simple creating:

set ext = new DocExt( doc, "" )

The conditional creating:

if not DEdocLocked( doc ) then

set ext = new DocExt( doc, "" )

end if

At the conditional creating of an object ( ext ) the document ( doc ) is checked for its locking by the config DocExt\Doc. If the document isn't locked, the function DEdocLocked returns the result False (0).

The typical code which you should type in the event PostOpen of a form:

if source.isNewDoc then

set ext = new DocExt( doc, "" )

elseif source.editMode then

source.editMode = not DEdocLocked( doc )

if source.editMode then

set ext = new DocExt( doc, "" )

end if

end if


Object processing

The processing of a DocExt object performs all validations provided by its config DocExt\Doc on the object's document, and then, if the validations have been passed successfully, updates all related documents with changes logging.

To call a DocExt object's processing in your script you must call the object's method named Update. The method should be called before the document will be saved. Thus for a UI document changing by a user through its form you should call the DocExt object's processing in the event QuerySave of the form. For a back-end document you should call the DocExt object's processing just before the document saving in a code.

The method Update returns a result: True (-1) or False (0). The result True means that all validations of the document were successfully passed and related documents have been updated. The validations are defined by the items Doc and the updates are defined by the items DocUpDoc of the config DocExt related to the document by the name of its form.

Type the code in form's event QuerySave to call the processing of a DocExt object ( ext ) at the UI document saving:

continue = false

continue = ext.update( "" )

Type the code to call the processing of a DocExt object ( ext ) at the back-end document saving ( doc ):

if ext.update( "" ) then doc.save( true, false )


Topic links:

DocExt config

Function DEdocLocked

See also:

Script library DocExtLib