Lotus Notes / Domino Sonstiges > Tipps und Tricks

Modify a rich text field in the UI without having to save and re-open

(1/2) > >>

TMC:
Modify a rich text field in the UI without having to save and re-open


--- Code: ---Sub Click(Source As Button)
   Dim s As New NotesSession
   Dim ws As New NotesUIWorkspace
   Dim thisdb As NotesDatabase
   Dim coll As NotesDocumentCollection ' collection returned from PickListCollection
   Dim otherdoc As NotesDocument ' this is the doc to create a link to
   Dim thisdoc As NotesDocument ' the new doc that the link is being added to
   Dim rtitem As NotesRichTextItem ' required for AppendDocLink
   Dim nitem As Variant ' used to get a handle on the NotesRichTextField
   Dim olduidoc As NotesUIDocument ' the original instance of the uidoc
   Dim newuidoc As NotesUIDocument ' the new instance of the uidoc after the doc link has been added
   
   Set thisdb = s.CurrentDatabase
   Set olduidoc = ws.CurrentDocument ' current uidoc
   Set thisdoc = olduidoc.Document ' doc in memory but hasn't been saved yet
   
' select the doc to link to
   Set coll = ws.PickListCollection( PICKLIST_CUSTOM, False, thisdb.Server, _
   thisdb.FilePath, "luProject", "Project List", "Please select a project." )
   
' if a doc isn't selected exit
   If coll.Count = 0 Then
      Messagebox "User canceled" ,,"No project was selected."
      Exit Sub
   End If
   
' get the doc to link to
   Set otherdoc = coll.GetFirstDocument
   
' grab some values from that doc
   thisdoc.ProjectName = otherdoc.ProjectName
   thisdoc.CustomerName = otherdoc.CustomerName
   
' get the RichTextField in the current uidoc
   Set nitem = thisdoc.GetFirstItem( "ProjectDocLink" )
   
' add the doc link
' NOTE: this is being done to the backend doc that exists in memory
   If ( nitem.Type = RICHTEXT ) Then
      Set rtitem = nitem
      Call rtitem.AppendDocLink(otherdoc, "Original Doc Link", "")
      Call rtitem.Update
   End If
   
' 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
   Call olduidoc.Close(True)
   
' create a new uidoc and open the backend doc that is still in memory with added doc link
   Set newuidoc = ws.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 = newuidoc.Document
   
' remove the SaveOptions field so the doc can be saved
   Call thisdoc.RemoveItem( "SaveOptions" )
   
End Sub
--- Ende Code ---

Klappt allerdings nur ab R6 aufgrund "Call rtitem.Update".

adminnaddel:
Hallo liebe Gemeinde,

warum zum Donnerhack bekomme ich denn folgende Fehlermeldung?:

"Couldn´t get default View id for database (yxz.nsf)

Bitte einen kleinen Tipp!

PS .. hoffe schöne Weihnachtstage gehabt zu haben! ;D

lg
Andy

koehlerbv:
Hast Du denn eine Default view ?

Bernhard

mibo11:
Hallo Andy,

wie die nachricht schon sagt: In der Datenbank gibt es keine Standardansicht.

Einfach eine Ansicht als Standardansicht definieren, dann sollte es klappen.

Gruß Sascha

mibo11:
Übrigens sind wir hier bei Tipps und Tricks gelandet, kann einer der Moderatoren dies vielleicht einmal verschieben?

Navigation

[0] Themen-Index

[#] Nächste Seite

Zur normalen Ansicht wechseln