Autor Thema: Modify a rich text field in the UI without having to save and re-open  (Gelesen 5496 mal)

Offline TMC

  • Freund des Hauses!
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 3.660
  • Geschlecht: Männlich
  • meden agan
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

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

A good programmer is someone who looks both ways before crossing a one-way street.


Offline adminnaddel

  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 819
  • Geschlecht: Männlich
  • What a wonderful girl, so beautiful und se....;-)
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

Offline koehlerbv

  • Moderatoren
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 20.460
  • Geschlecht: Männlich
Hast Du denn eine Default view ?

Bernhard

Offline mibo11

  • Senior Mitglied
  • ****
  • Beiträge: 325
  • Geschlecht: Männlich
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

Offline mibo11

  • Senior Mitglied
  • ****
  • Beiträge: 325
  • Geschlecht: Männlich
Übrigens sind wir hier bei Tipps und Tricks gelandet, kann einer der Moderatoren dies vielleicht einmal verschieben?

Offline koehlerbv

  • Moderatoren
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 20.460
  • Geschlecht: Männlich
Sascha, ich würde sagen, der Fred ist hier schon richtig - der Ausgang ist ja ein Tipp.

Bernhard

Offline adminnaddel

  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 819
  • Geschlecht: Männlich
  • What a wonderful girl, so beautiful und se....;-)
Danke .... wie unschlau von mir ;D!! Setze auf erledigt!!!

lg
Andy

Lösung: DefaultView OK!

Offline mibo11

  • Senior Mitglied
  • ****
  • Beiträge: 325
  • Geschlecht: Männlich
Sascha, ich würde sagen, der Fred ist hier schon richtig - der Ausgang ist ja ein Tipp.

Bernhard

Habe mich ebenfalls gerade gefragt, ob sich Andys Beitrag nicht vielleicht auf den Tip bezog. Vielen Dank für die Aufklärung, es ist halt schon spät im Jahr.

Gruß Sascha

 

Impressum Atnotes.de  -  Powered by Syslords Solutions  -  Datenschutz