LotusScript Question - NotesUIDocument.FieldSetText

I want to be able to read documents from a NotesDocumentCollection and for each document pick certain filed values and then write these filed values as one row in a table. When I get to the next document in the collection I want to read the same field values and write them to the same row on the table but with a new line as separator which simulates a dynamic table. My problem is that the initial filed values are being overwritten as a result only the field values from the last document in the collection show up. How do I get around this ?

Thanks in advance!!

Subject: LotusScript Question - NotesUIDocument.FieldSetText

Show us your code, young man!

Not knowing exactly what it is you are assigning makes it impossible to give a precise answer, but remember that the FieldSetText method will only work with an honest-to-goodness string. Just how are you building the replacement text? Just by way of example, here’s how I’d go about it:

dim dc as notesdocumentcollection

dim doc as notesdocument

dim uidoc as notesuidocument

dim tmpText as String

dim rowCounter as Integer

[insert instantiations here]

tmpText=“”

rowCounter=1

Set doc=dc.getFirstDocument

Do until doc is Nothing

tmpText=tmpText+doc.itemvalue(0)

if Not rowCounter=dc.Count Then tmpText=tmpText+chr(10)

rowCounter=rowCounter+1

Set doc=dc.getNextDocument(doc)

Loop

Call uidoc.fieldSetText(“newitem”, tmpText)

Hope this helps.

Subject: RE: LotusScript Question - NotesUIDocument.FieldSetText

My code follows:

Dim session As New NotesSession

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim doc,vdoc As NotesDocument

Dim coHandle As String

Dim db As NotesDatabase

Dim view As NotesView

Dim coll As NotesDocumentCollection

Set db = session.CurrentDatabase

Set uidoc = ws.CurrentDocument

Set vdoc = uidoc.Document

coHandle = uidoc.FieldGetText(“pfCoName”)

'Msgbox(coHandle)

Set view = db.GetView(“Members\EmployerName”)

Set coll = view.GetAllDocumentsByKey(coHandle)

'Msgbox(coll.Count)

Set doc = coll.GetFirstDocument

Do Until doc Is Nothing

Call uidoc.FieldSetText(“dJ”, _Cstr(doc.regDate(0)))

Set doc = coll.GetNextDocument(doc)

Loop

I want to generate a statement for a client. So I compose a new document with the client profile selected. This picks up the name of the client and I use this as my key to pick all docs pertaining to employees of that company. I now have a document collection. Now on the document that I have composed I have a single row table and I want to list info from values coming from docs in the collection. If my doc collection has 3 doc, then I will have a loop reading values from the 3 docs and writing to my open document.

Subject: RE: LotusScript Question - NotesUIDocument.FieldSetText

The answer’s simple: see Chuck’s code. In your loop, you’re just over-writing anything you’ve set in the “dJ” ui doc field with the next document’s value – you need to append, not replace!

Do Until doc Is Nothing

Call uidoc.FieldSetText("dJ", Cstr(doc.regDate(0)))

Set doc = coll.GetNextDocument(doc)

Loop

HTH

Subject: RE: LotusScript Question - NotesUIDocument.FieldSetText

If I append, it does not overwrite but its writing the values in 1 line eg. value1value2value3, yet what i want is to have the info as follows:value1

value2

value3

I have set the field to accept multiple values and values to be seperated by a new line.

Thanks

Subject: RE: LotusScript Question - NotesUIDocument.FieldSetText

OK, you probably need to play with what delimiters are used for input in the field in question, not just how those multi-values are presented. For example, if multi-values are separated on input by a semi-colon, then you need to include that char when you set the field text in your code.

Subject: Maybe I am just being dumb…

…but when I include a semi-colom(which is what I have designated on “Seperate values when user enters” on Field Properties and I have set it to display multi values with a new line separator all i get is value1;value2;value3.

I am surely stumped !!

Subject: RE: Maybe I am just being dumb…

I would stick with one type of delimiter for both display and storage, that is, use a Newline throughout (no other value).

If you stick with one value you will be able to see what is going on. If you use more that one value then it becomes confusing.

Next, make sure that the display field is set to allow Multi-values.

Rolf Pfotenhauer

Subject: RE: Maybe I am just being dumb…

If I remember rightly, Notes doesn’t actually dispay the multiple values on separate lines in Edit mode, only in Read mode. Is it displaying your values all on the same line in Read mode, once you have saved and reopened the document?

Subject: RE: Maybe I am just being dumb…

Thanks All, once I save the doc it then displays in seperate lines.

Thank You

Subject: All you really have to do is a uidoc.Refresh. No need to .Save it.