Fausto Leuci 17.Jul.09 11:47 AM a Web browser General6.0All Platforms
A question:
i have an agent lotusscript that , given a db lotus, create a report csv (one file for each form in db) in which there all fields of form (one per column) and in each rows there is an element(document) of that forms.
each column contain in the header the name of field.
Example:
Field1; FIELD2; FIELD3;...
Instead I would like to have this:
field1(Type_of_field1);field2(Type_of_filed2);field3(Type_of_filed3);...
How could i take type of filed in a form?
There is not filed.type property.
when i take this:
Set rtitem=doc.GetNthElement(x);
Messagebox rtitem.type
i get a number (1024, 1028 etc), but i don't get "Text", "Rich Text" "Date" etc.
Could you give me a piece of code in which you show me how could i get name of field (only this i get for now) and corresponding type of field?
Thanks a lot!
My code is:
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim fileName As String
Dim fileNum As Integer
Dim headerstring As String
Dim values As String
Dim selection As String
Dim collection As NotesDocumentCollection
Dim doc As notesdocument
Dim tipoField As String
On Error Resume Next
Set db = session.CurrentDatabase
Forall form In db.Forms
If Isempty(form.Fields) Then
Messagebox form.Name & " has no fields"
Else
fieldCount = 0
msgString = ""
fileNum% = Freefile()
fileName$ ="D:\ExportDBsLotus\DES_Storico\" & form.Name & ".csv"
Open FileName$ For Output As fileNum%
Forall field In form.Fields
tipoField =form.GetFieldType(field)
msgString = msgString & Chr(10) & _
" " & field
fieldCount = fieldCount + 1
headerstring=headerstring & |"| & field & |";|
End Forall
Write #fileNum%, |";| & headerstring & |"|
headerstring=""
End If
selection = |Form="| & form.Name & |"|
Set collection=db.Search(selection,Nothing, 0)
For x = 1 To collection.count
Set doc =collection.GetNthDocument(x)
values=""
Forall formfield In form.Fields
newvalue=doc.GetItemValue(formfield)
values=values & |"| & newvalue(0) & |";|
End Forall
Write #fileNum%, |";| & values &|"|
values=""
Next
'controllo aliases
If Isempty(form.Aliases) Then
Else
Forall aliaz In form.Aliases
If aliaz = form.Name Then
Msgbox aliaz + " is same as " + form.Name
Goto NextAliaz 'alias uguale a nome form
End If
selection = |Form="| & aliaz & |"|
Set collection=db.Search(selection, Nothing, 0)
For x = 1 To collection.count
Set doc =collection.GetNthDocument(x)
values=""
Forall formfield In form.Fields
newvalue=doc.GetItemValue(formfield)
values=values & |"| & newvalue(0) & |";|
End Forall
Write #fileNum%, |";| & values &|"|
values=""
NextAliaz:
Next
End Forall
End If