Domino 9 und frühere Versionen > ND6: Entwicklung

Typisch Notes

<< < (7/8) > >>

Tode:
diese ganze Diskussion ist ja wirklich schön und gut, und alles was Du sagst ist richtig @Axel.

Trotz allem müssen wir in diesem Forum nicht aus jeder Frage eine Grundsatzdiskussion machen.
Du hast recht: Als ich in die Diskussion eingestiegen bin, habe ich mit meiner Antwort das Thema verfehlt..

Das einzige, worauf ich mit meinem Post hinweisen wollte, war, dass dem Fragesteller höchst- wahrscheinlich mit dieser kurzen Information schon geholfen gewesen wäre, ohne dass er gleich zum Script- Experten werden muss...

Und jetzt könnt Ihr ja gerne in dieser -durchaus interessanten- Diskussion fortfahren.

Gruß
Tode

MadMetzger:
Ich habe mich meiner Klasse nochmal angenommen und einen Hinweis von Norbert einzubauen:

--- Zitat von: LN4ever am 04.03.07 - 21:57:24 ---Immer, wenn ich beim Kopieren irgendwo "GETFIRSTITEM" lese, denke ich mir, daß die Methode nicht umsonst so heißt - daß es also mehrere gleichnamige Feld(Teile) geben kann.
Und da sind wir mitten im Schlamassel. Die Klassenmethode muß also letztlich mehr leisten, z.B. das Dokument erst einmal in ein neues virtuelles Dokument kopieren und in dem die ITEMS durchorgeln. Bei einem Kopierkandidaten dann das gefundene GETFIRSTITEM removen und nach einem weiteren GETFIRSTITEM des gleichen Namens suchen usw.

--- Ende Zitat ---
Jedoch frage ich mich gerade, wann ein Item mehrmals vorhanden sein soll und woran man das erkennen kann. Intuitiv dachte ich zuerst, dass man das an den Dokumenteigenschaften erkennen kann (siehe Screenshot im Anhang), wenn ein Feldname mehrmals auftaucht. Scheinbar ist das aber so nicht korrekt, denn wenn ich meine modifizierte Klassse in der ich mit dem virtuellen Dokument arbeite auf diesem Dokument aufrufe, durchläuft er mir meine Schleife, die so lange Items entfernen und kopieren soll, nur ein einziges mal. Kurioserweise taucht das Item im Debugger aber auch nur ein einziges mal auf.

Hier die Schleife:

--- Code: ---'iterate over the map of field names
Forall entry In Me.fieldMap
Dim item As NotesItem

'get item the first time
Set item = virtual.GetFirstItem(Listtag(entry))

Do
'copy item to new document, as long as there are items with the same name
Call item.CopyItemToDocument(newDoc,entry)
Call item.Remove()
'Set item = Nothing
Set item = virtual.GetFirstItem(Listtag(entry))
Loop Until item Is Nothing
End Forall
--- Ende Code ---
Ich frage mich gerade ob ich jetzt falsch denke oder ob LS vielleicht mehrere gleichnamige Items zu einem wieder zusammensetzt...  ???

Glombi:
Ein Item kann mehrfach vorkommen, wenn

1. man es mit doc.AppendItemValue erzeugt. Bei jedem Aufruf wird ein neues Item geschrieben, auch wenn es bereits ein Feld mit dem gleichen Namen gibt.
Wer sich das wieder bei IBM ausgedacht hat  ::)

Immerhin stehts ja deutlich in der Hilfe:

--- Zitat ---Hinweis  In general, ReplaceItemValue is favored over AppendItemValue. If an item of the same name already exists in a document, AppendItemValue creates a second item of the same name, and the duplicate items are not accessible except through a work-around. If you are creating a new document, AppendItemValue is safe.

--- Ende Zitat ---

2. es sich um ein Rich Text Feld handelt. Ich vermute mal, das Notes die Dinger jeweils nach 64 K stückelt.

Andreas

Glombi:
und dann noch den:

LotusScript Code Produces Two Rich Text Fields of the Same Name in Notes
Product:
Lotus Notes  >  Lotus Notes  >  Versions 6.0, 5.0, 4.6, 4.5, 6.5
Platform(s):
Platform Independent
Doc Number:
1097725

   Lotus Domino  >  Lotus Domino Designer  >  6.x, 5.x
Platform Independent


Published   09.12.2004
Technote

Problem

The Document Properties on a Notes document shows two entries for the same Rich Text field (RTF).



Solution
This issue occurs on documents that use LotusScript to create or update the Rich Text field.  Two or more Rich Text fields will appear in the Document Properties until the document is edited and saved in the front-end or user interface.  This issue was reported to Quality Engineering and it was determined that Notes is working as designed.

This issue has been observed with the following methods under Notes 4.5x/4.6x/5.x/6.x (with the exception noted):

CreateRichTextItem -    Note: This method does not cause the issue under Notes R5. 
AddNewLine
AppendText
EmbedObject

CreateRichTextItem example:

Call doc.RemoveItem("RTF")
Set rtitem = doc.CreateRichTextItem("RTF")
Call rtitem.AppendText(value)

AddNewLine example:

Set rtitem=doc.getfirstitem("RTF")
Call rtitem.addnewline(1)

AppendText example:

Set rtitem=doc.getfirstitem("RTF")
Call rtitem.appendtext("add some text")


EmbedObject example:

     Set rtitem = New NotesRichTextItem( doc, "Body" )
     Set object = rtitem.EmbedObject ( EMBED_ATTACHMENT, "", "d:\work\test.txt")


Note:  You may observe that using the New method with the NotesRichTextItem class will produce only one field entry.  This is actually undesirable as the Item is not properly added to the Document object.  See the related document noted below.

Example:

Call doc.RemoveItem("RTF")
Dim rtitem as New NotesRichTextItem(doc, "RTF")
Call rtitem.AppendText(value)

Supporting Information:

IMPORTANT NOTE:  The above is a sample script, provided only to illustrate one way to approach this issue.  Notes Support will not be able to customize this script for a customer's own configuration.

Workaround:

WARNING:  This workaround below should not be used with Notes Release R5.  Under Notes R5 the code below will delete the RTF field completely and data will be lost.   The workaround below is applicable only to 4.5x/4.6x.   The workaround should not be applied to documents which have been saved in the user interface (UI); this is because saving the document in the user interface clears the second unwanted RTF field.   It is recommended that the workaround (that is, using the NotesItem Remove method) be applied in only the same agent that creates the Rich Text field.   

Example:

Set rtitem = doc.CreateRichTextItem("RTF")
Call rtitem.AppendText(value)
' We have now 2 Body fields
Set rtitem = doc.GetFirstItem( "RTF" ) ' we return to the first body field
Call rtitem.Remove                                     ' we remove it

Related Documents:

In The Document Properties a Field Has Entries For Text and Rich Text
Document #:  1103415   (180058)   

MadMetzger:
Hm... irgendwie helfen mir diese Sachen nichts.

Ich sehe bei sowohl bei altem Dokument (s. früheres Posting der Screenshot) als auch beim neuen Dokument (s. hier der Screenshot) das Item mehrfach, aber bei  Betrachtung im Debugger ist es nur einmal da. Das ist es was mich wundert... Von mir aus können die Items ja mehrfach vorkommen, das soll ja gerade dieses Script mit abdecken... Nur erscheint mir das gerade nicht wirklich erforderlich, wenn das Item ja eh nur einmal im Debuger beim Dokument unter Items auftaucht.

Navigation

[0] Themen-Index

[#] Nächste Seite

[*] Vorherige Sete

Zur normalen Ansicht wechseln