Hi All,
I am new in developing using Lotus Domino. Please be patient on my very simple question, I really need your help.
Field A having the existing data, and in the Postopen event, I would like to assign A to field B. But how can I do this?
I write:
doc.B = doc.A(0)
But the value A doesn’t show in the B field. What is wrong?? AfterI save it, and reopen the form, only the value appear in B field.
I need to assign value in field A to field B and later I need to write some coding to refer to field B. But now I can’t do this, coz it always return me null value in field B.
I thought this is a very simple programming, I have been using Power Builder and VB for 3 years, but this Lotus Domino seems quite different.
Please help, this simple coding took me one whole day to solve.
Thanks very very much.
Subject: Simple Question - Assign value to the field
Shelyn,
It is all to do with the concept of back-end and front-end.
Instead of doc.B, you need to use the “fron-end” classes (what Notes refers to as the UI document - NotesUIDocument class)
The line should read call uidoc.fieldsettext(“B”, doc.A(0))
HTH
Mike
Subject: RE: Simple Question - Assign value to the field
Thanks a lot Mike!! It works well.
Does it mean uidoc.fieldsettext is front end classes?
Subject: RE: Simple Question - Assign value to the field
It is!
And the back-end of the UI document is NotesUIDocument.Document (once the doc has been saved into memory)
Subject: RE: Simple Question - Assign value to the field
Hi Mike,
But FieldSetText can only be used in the EditMode = true.
I need to do it in the postopen event, in which the EditMode is False. How can I modify the coding?
Thanks again.
Subject: RE: Simple Question - Assign value to the field
You can’t make document changes in read mode. If you need to set and save the value, move the code to the QueryOpen event and save the document before it is opened. If you don’t need the value to persist in the database, make FieldB “computed for display”.
Subject: RE: Simple Question - Assign value to the field
But it prompt me the error that:
Property or method is not available during QueryOpen event - FieldSetText
And also another question, why I failed to compare doc.A and doc.B? Both of them are retrieved from the document.
Subject: RE: Simple Question - Assign value to the field
Don’t use FieldSetText – that can ONLY be used on a document open to the UI in edit mode. Set the back-end value and save the document.
Subject: RE: Simple Question - Assign value to the field
This is my coding
Sub Queryopen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant, Continue As Variant)
Set ws = New NotesUIWorkspace
Set session = New NotesSession
Set Currdb = session.CurrentDatabase
Set uidoc = source
Set doc = uidoc.Document
If (doc.CurrEgmtPrt(0) <> doc.EgmtPrt(0)) Or (doc.CurrYrEnd_EgmtPrt(0) <> doc.YrEnd_EgmtPrt(0)) Then
doc.CurrEgmtPrt = doc.EgmtPrt(0)
doc.CurrYrEnd_EgmtPrt = doc.YrEnd_EgmtPrt(0)
Call doc.save(False, False)
End If
End Sub
The IF condition doesn’t work, even though both value are different. And even if I take out the If condition and save the record, the assigned value (doc.CurrEgmtPrt) was not shown in the field.
Subject: RE: Simple Question - Assign value to the field
Does EgmtPrt exist on the document? Examine the document from the view by right-clicking and using the document properties. Oh, and don’t assign Source to another variable. There’s no need to declare a workspace, session or database:
Sub Queryopen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant, Continue As Variant)
Dim doc As NotesDocument
Set doc = Source.Document
If (doc.CurrEgmtPrt(0) <> doc.EgmtPrt(0)) Or (doc.CurrYrEnd_EgmtPrt(0) <> doc.YrEnd_EgmtPrt(0)) Then
doc.CurrEgmtPrt = doc.EgmtPrt(0)
doc.CurrYrEnd_EgmtPrt = doc.YrEnd_EgmtPrt(0)
Call doc.save(False, False) End If
End Sub
Subject: RE: Simple Question - Assign value to the field
It still doesn’t work. Yes, EgmtPrt does exist on the document. It already has the data in it. When debug, EgmtPrt has the value and CurrEgmtPrt is empty, but the it doesn’t go into the If condition.
Even if I took out the If condition and let it save the value, the CurrEgmtPrt value doesn’t appear on the screen. So when I do this coding when user click on Add button:
Sub Click(Source As Button)
Set uidoc = ws.CurrentDocument
Set doc = uidoc.Document
Dim YrEnd As String
YrEnd = Right$(Cstr(doc.YrEnd_EgmtPtr(0)), 7)
Call doc.GetFirstItem("PrevEgmtPtr").AppendToTextList(doc.CurrEgmtPrt)
Call doc.GetFirstItem("PrevYrEnd_EgmtPtr").AppendToTextList(doc.CurrYrEnd_EgmtPrt)
Call uidoc.FieldSetText("CurrEgmtPrt", doc.EgmtPtr(0))
Call uidoc.FieldSetText("CurrYrEnd_EgmtPrt", YrEnd)
End Sub
It retrieve nothing from the CurrEgmtPrt, hence no value append to the PrevEgmtPrt list.
Please help, what have I done wrong?
Subject: RE: Simple Question - Assign value to the field
It seems to me that something else is clearing the value. Value formulas? Input Translation? (I still think this is a silly idea, since you can accomplish what you want to do by simply using a computed field.)