Domino 9 und frühere Versionen > ND6: Entwicklung
Form von UIDoc herausfinden
Fedaykin:
Ich habe das Problem, dass ich in Lotusscript den Namen der Form eines neuen Dokumentes bräuchte. Da das Dokument aber noch nicht gespeichert ist, ist dieser nicht verfügbar. Hier noch mein Code, hoffe jemand hat eine Idee. Geht dabei darum Anhänge einzufügen ohne das Dokument zuvor speichern zu müssen.
Sub Initialize
Dim ws As New NotesUIWorkspace
Dim filenames As Variant
filenames=ws.OpenFileDialog(False,"Bitte Anhang wählen!","Text Dateien|*.txt|Notes Templates|*.ntf","M:\")
If Not(Isempty(filenames)) Then
AddAttachment ws,"fa_Person","ParentUID",filenames(0)
End If
End Sub
Sub AddAttachment(uiws As NotesUIWorkspace, FormName As String,ItemName As String,FileName As String)
Dim uidoc As NotesUIDocument
Dim ws As New NotesUIWorkspace
Dim thisdoc As NotesDocument
Dim rtitem As NotesRichTextItem
Dim olduidoc As NotesUIDocument
Set olduidoc=uiws.CurrentDocument
Set thisdoc = uiws.CurrentDocument.Document ' doc in memory but hasn't been saved yet
thisdoc.RemoveItem ItemName
Set rtitem = New NotesRichTextItem (thisdoc,ItemName)
rtitem.EmbedObject EMBED_ATTACHMENT, "", FileName
rtitem.Update
thisdoc.Form=FormName
' set the SaveOptions field so that when the uidoc is closed, the user won't be asked to save
thisdoc.SaveOptions = "0"
' close the uidoc. It won't actually happen until the code is finished executing
olduidoc.Close False
' create a new uidoc and open the backend doc that is still in memory with added doc link
Set uidoc = uiws.EditDocument(True, thisdoc)
' delete the reference to the old uidoc
' this is necessary because the code below affects it if left in memory
Delete olduidoc
' re-associate the variable with the backend doc
' have to do this because the olduidoc reference was deleted
Set thisdoc = uidoc.Document
' remove the SaveOptions field so the doc can be saved
thisdoc.RemoveItem "SaveOptions"
uidoc.Refresh
End Sub
Glombi:
In so einem Fall muss man ein Feld namens "Form" in die Maske einbauen und dort den Maskennamen bzw. Alias eingeben.
Dann kannst Du das bereits im Postopen auswerten.
Andreas
Fedaykin:
Hallo Andreas
Ein "Berechnet zur Anzeige" Feld mit der Formel "@If(Form="";@ThisValue;Form)" reicht aus, aber halt wieder eine Abhängigkeit an die man bei jeder Verwendung denken muss. Mit Evaluate rausfinden funktioniert leider auch nicht. Frage mich wie Notes überhaupt weiss was da rein schreiben. ;)
Gruss
Remo
jmanuel:
--- Zitat von: Fedaykin am 28.07.04 - 13:00:38 ---
Ein "Berechnet zur Anzeige" Feld mit der Formel "@If(Form="";@ThisValue;Form)" reicht aus,
--- Ende Zitat ---
Hallo,
diese Formel funktioniert aber auch erst nach dem Speichern eines Dokuments. Gibt es wirklich keine Möglichkeit, den Maskennamen vor dem Speichern herauszufinden ??
echt seltsam!
Semeaphoros:
Das ist richtig, dass man auf den Standardwert "Form" erst nach dem Speichern zugreifen kann. Aber was spricht denn dagegen, ein berechnetes Feld namens Form zu machen, in dem der Name hardcodiert drin steht? Problematisch ist dabei nur die Pflege der Maske, denn wenn der Maskenname geändert wird, muss man auch daran denken, dieses Feld zu ändern.
Navigation
[0] Themen-Index
[#] Nächste Seite
Zur normalen Ansicht wechseln