Page 1 sur 1
Peut-on connaitre le nombre de champ d'un document ?

Publié:
03 Nov 2010 à 11:06
par jordane45
Bonjour,
Est-il possible (en lotusscript ) de connaitre dans le document en cours :
- Le nombre de champs
- Leurs noms
- Leurs valeurs
j'ai parcourue l'aide du desiner ainsi que le net, mais sans résultat.
Cordialement
Jordane.

Publié:
03 Nov 2010 à 11:24
par amahi
Bonjour
Tu as la methode items qui te renvoie l'ensemble des champs dans un tableau.
A partir de la tu as le nombre champ (= la taille de ton tableau) et pour chaque item tu as les propriété Name et Values qui te renvoie respectivement le nom et les valeurs de ton champ.

Publié:
03 Nov 2010 à 11:43
par Michael DELIQUE
salut
une vieille fonction qui renvois le nom de tous les champs présent dans un document
- Code : Tout sélectionner
Function FieldList(wDB As NotesDatabase, wForm As String, wDoc As NotesDocument) As Variant
'Déclaration de variables
Dim lstValue List As String
Dim Selection As String
Dim i As Integer
Dim DB2 As NotesDatabase
Dim FRM As NotesForm
Dim vrItem As Variant
On Error Goto ErreurHandle
Erase lstValue
lstValue(0) = ""
i = -1
If Trim(wForm) = "" And (wDoc Is Nothing) Then
FieldList = lstValue
Erase lstValue
Exit Function
Elseif Trim(wForm) <> "" And (Not wDoc Is Nothing) Then
FieldList = lstValue
Erase lstValue
Exit Function
End If
If wDB Is Nothing Then
Set Session = Nothing
Set Session = New NotesSession
Set Db2 = Session.CUrrentdatabase
Else
Set Db2 = wDB
End If
If Trim(wForm)<>"" Then
'recherche sur un masque/form
Set FRM = Db2.GetForm( Trim(wForm) )
If FRM Is Nothing Then
' Mess = "Formulaire introuvable.",48," ATTENTION !"
FieldList = lstValue
Erase lstValue
Exit Function
End If
Forall Value In FRM.fields
i = i+1
lstValue(i) = Value
End Forall
Else
'recherche sur un document
If wDoc Is Nothing Then
' Mess = "Document is nothing",48," ATTENTION !"
FieldList = lstValue
Erase lstValue
Exit Function
Else
vrItem = wDoc.Items
Forall value In vrItem
i = i+1
lstValue(i) = Value.name
End Forall
vrItem = Null
End If
End If
i = 0
Selection = ""
FieldList = lstValue
Erase lstValue
Set Db2 = Nothing
Exit Function
ErreurHandle:
Msgbox "("+Structure_Log+" : "+Cstr(Getthreadinfo (1))+" Call by "+Cstr(Getthreadinfo(10))+")"+Chr(10)+"Erreur " + Str(Err) + " : "+Chr(10) + Cstr(Error)+". "+Chr(10)+"Ligne N° "+Cstr(Erl),16," ERREUR !"
lstValue(0) = ""
FieldList = lstValue
Erase lstValue
Exit Function
End Function

Publié:
03 Nov 2010 à 11:46
par Michael DELIQUE
sinon un exemple plus simple
- Code : Tout sélectionner
Dim Doc As NotesDocument
Dim item As NotesItem
Dim nbfield As Integer
nbField = Ubound(Doc.Items)
Msgbox "nb fields : "+Cstr(nbField)
Forall value In Doc.Items
Set Item = value
Msgbox "Champ : "+Item.Name+Chr(10)+"Valeur : "+item.Text
End Forall

Publié:
03 Nov 2010 à 11:58
par jordane45
Merci beaucoup.
amahi, j'ai testé avec ta proposition et c'est ok. je récupère bien les informations dont j'avais besoin.
Michael DELIQUE : je viens juste de voir ta réponse. Je vais m'y pencher car cela à l'air très interessant.
Encore merci à vous deux.
Bonne journée.
Jordane

Publié:
03 Nov 2010 à 12:13
par jordane45
Bon, je viens de voir que ton exemple (plus simple);.; c'est ce que je venais de faire.
Parfait !
Merci encore.