Custom classes and scope?

Ok… I am at a loss here. I’ve created custom classes many times before, usually just dealing with strings, lists, arrays, and integers. This is the first time I have tried to have a property be equal to a notes class (a NotesRichText Item).

I have a config class (below) that is called from a button click event (the buttom creates a new document). It gathers settings from different configuration documents on several databases. The issue I am having is with two of class properties. There are several string properties, such as reqfields, which populate properly and are accessable. However, the two disclaimer fields (NotesRichTextItems) are null or nothing. They DO populate when the class is being built (through the new event). However, upon leaving the NEW event, the two properties revert to nothing. It is like they are not within the scope, yet ALL the other properties (which are strings and integers) stay assigned; it is only these two which go away.I even tried the “get” method and that throws an error (Not a member) Am I missing something?

Thank you for your help,

Jim

'////////////////////

Class config

’ (Remark: … extra code removed)

'…

Private m_reqfields As String

Private m_disclaimerABC As NotesRichTextItem

Private m_disclaimerCBA As NotesRichTextItem

'…

'// getters

'…

Public Property Get reqfields As String

	reqfields = Me.m_reqfields

End Property

Public Property Get disclaimerABC As NotesRichTextItem

	Set disclaimerABC = Me.m_disclaimerABC

End Property

Public Property Get disclaimerCBA As Notesrichtextitem

	Set disclaimerCBA = Me.m_disclaimerCBA

End Property

'…

'// setters

Public Property Set reqfields As String

	Me.m_reqfields = reqfields

End Property

Public Property Set disclaimerABC As NotesRichtextItem

	Set Me.m_disclaimerABC = disclaimerABC

End Property

Public Property Set disclaimerCBA As NotesRichTextItem

	Set Me.m_disclaimerCBA = disclaimerCBA

End Property

'// Public Methods

Public Sub new

	Call Me.load

End Sub





Public Function load As Boolean

'…

	Dim s As New NotesSession

	Dim db As NotesDatabase

	Dim cfgdoc As NotesDocument

	Set db = s.CurrentDatabase

	Set cfgdoc = db.GetProfileDocument("cfgProfile")

'…

	Me.reqfields = getItem(cfgdoc,"reqFields")

	Set Me.disclaimerCBA = getRTItem(cfgdoc,"disclaimerCBA")

	Set Me.disclaimerABC= getRTItem(cfgdoc,"disclaimerABC")

	load =True		

	Exit Function		

loadfailure:

	load = False

End Function	

'// Private Methods

Private Function getItem(cfgdoc As Notesdocument, itemName As String) As String

	Dim it As NotesItem

	Set it = cfgdoc.GetFirstItem(itemName)

	Dim t As String

	Dim c As Integer

	c = Ubound(it.Values)

	Select Case c

	Case Is < 0:

		getItem = ""

	Case  0:

		getItem = it.text

	Case Else

		Forall x In it.Values

			t = t + x + Chr(10) + Chr(13)

		End Forall

		getItem = t

	End Select

End Function



Private Function getRTItem (cfgdoc As NotesDocument,itemname As String) As NotesRichTextItem

	Set getRTItem  = cfgdoc.GetFirstItem(itemName)

End Function

End Class

’ -------Button event ---------------------

Sub click(source as button)

Dim session As New NotesSession

Dim ws As New NotesUIWorkspace

Dim db As NotesDatabase

Dim doc As NotesDocument

Set db = session.CurrentDatabase

Set doc = db.CreateDocument

Dim cfg As New config

doc.reqfields = cfg.reqfields	

doc.disclaimer = cfg.disclaimerABC

’ doc.disclaimer = cfg.get(“disclaimerABC”)

Call doc.disclaimer.update()

End Sub

Subject: Custom classes and scope?

Strictly a guess

A NotesRichTextItem does not exist on its own, it is valid only in the context of a NotesDocument.

Hence, the creation of a NotesRichTextItem requires that you specify the document.

After creating the class, you discard the document since it is valid only within the Button source. Therefore, the NotesRichTextItems also go away.

Can you store the document in the class?