The problem is that there are some documents on my database that have more than one field called Files on them. By a happy mischance the Files field is rich text.Thru the Notes client the field(s) display correctly BUT I have to do stuff to them in Script.
Also the fields have various attachments in them, they also display correctly.
So far I have managed to show that Script can see all the fields. But it doesn’t seem to be seeing all the attachments. Hence the code I wrote to merge these fields which moves all attachments over is ‘losing’ data.
Has anyone else come across this problem?
Has anyone any bright ideas ?
All help gratefully received.
Sue
PS I’m pretty sure we used to have this sort of problem back in the R3/4 days but can’t quite put my finger on the solution.
Subject: A rich text conundrum
Sue,
This script doesn’t do exactly as you describe, but was written to eliminate certain types of file attachments from our mail files. Basically it loops through doc.Items and determines if the item in question is a rich text field and if it has an attachment in it. Perhaps it will give you some ideas.
Sub Initialize
Dim s As New NotesSession
Dim dbdir As NotesDbDirectory
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim item As NotesItem
Dim rtitem As NotesRichTextItem
Dim obj As NotesEmbeddedObject
Dim x As Integer
Dim y As Integer
Dim itemRemoved As Boolean
On Error Resume Next
Set dbdir = s.GetDbDirectory(SERVER)
Set db = dbdir.GetFirstDatabase(1247)
Do While Not (db Is Nothing)
If Instr(db.FilePath,MAIL) <> 0 Then
Call db.Open("","")
If db.IsOpen Then
Set dc = db.AllDocuments
Set doc = dc.GetFirstDocument
Do While Not (doc Is Nothing)
itemRemoved = False
If doc.HasEmbedded Then
Forall i In doc.Items
If i.Type = RICHTEXT Then
Set rtitem = i
If Not (Isempty(rtitem.EmbeddedObjects)) Then
Forall o In rtitem.EmbeddedObjects
If o.Type = EMBED_ATTACHMENT Then
Set obj = o
If isDeleteableFile(obj) Then
obj.Remove
itemRemoved = True
End If
End If
End Forall
End If
End If
End Forall
If itemRemoved Then
Set rtitem = doc.GetFirstItem(FIELD_BODY)
Call rtitem.AddNewline(2)
Call rtitem.AppendText(MSG_POLICY)
End If
doc.Save True, False
End If
Set doc = dc.GetNextDocument(doc)
Loop
End If
End If
Set db = dbdir.GetNextDatabase
Loop
End Sub
isDeletable was a function we wrote to determine if it was one of the files we were looking to delete.
hth.
brandt
Subject: A rich text conundrum
Hello
Every time a named field increases greater than the Notes limit, the client
creates a new field of the same name, especially with RTF, but with differents Dup Item IDs .
According to what you wanna do with them, you should consider explore the fields
with a
Forall it in doc.items
loop …
HTH