Domino 9 und frühere Versionen > Entwicklung

ArrayAppend (wieder mal)

<< < (2/3) > >>

Rob Green:
Hab das mal kurz in ein Button geschmissen und läuft prächtig, egal ob das Feld "Mult1" zu Beginn leer ist oder gefüllt wird später.

Dim Eintrag As String
   Eintrag = "neuer Eintrag um: " & Cstr(Today())
   Dim NWS As New NotesUIWorkspace
   Dim UIDOC As NotesUIDocument
   Dim Doc As NotesDocument
   Set UIDOC = nws.currentdocument
   Set Doc = UIDOC.document
   
   If doc.Mult1(0) = "" Then
      doc.Mult1 = Eintrag
   Else
      inhalt = doc.Mult1
      doc.Mult1 =  Arrayappend( inhalt, Eintrag )        
   End If
   
   Call doc.save(True, False)
   Set UIDOC = NWS.EditDocument( False , doc)
   

Don Pasquale:
@Rob

Mein Skript funktioniert nun, mit einer Einschränkung:
Das uidoc in dem der Button implementiert ist,
muß im Edit Modus sein.
Das Skript geht doch aber über das Backend ???


Function makeHistorieneintrag ( unid As String, User As String, Text As String) As Integer
   
   Set HEUTE = New NotesDateTime( "Heute" ) ' As String   
   Dim Eintrag As String
   Dim item As NotesItem
   
   Eintrag = Cstr(Heute.localtime) & " " & User & " " & Trim$(Text)
   Dim session As NotesSession
   Dim db As NotesDatabase
   Dim doc As NotesDocument
   Set session = New NotesSession
   Set db  = session.CurrentDatabase
   Set doc = db.GetDocumentByUNID(unid)
   
   
   
   If Not (doc Is Nothing) Then
      
      If doc.~$Historie(0) = "" Then
         Print "Neu : " & Eintrag
         doc.~$Historie = Eintrag
         Call doc.save(True,True)
      Else
         Print "Zusatz : " & Eintrag
         doc.~$Historie =  Arrayappend( doc.~$Historie, Eintrag )         
         Call doc.Save(True, False)
      End If
      
   End If
   
End Function

Rob Green:
hm..kratz..was ist groß anders als im ersten Posting bzw. nach dem IF Hinweis von Axel, wo Du ja meintest dat das auch nicht klappt?

Don Pasquale:
@Rob

Was war anders : doc.~Historie und doc.~$Historie

Ich habe mein Skript nun einmal aus einer Backend Routine angesprochen ( Collection mit dc.unprozessedDocuments),
da funktioniert alles tadellos.

Aus einem Uidoc heraus im Backend was zu verändern klappt nur
wenn das uidoc im edit modus ist


Skript aus dem Backend

   Dim session As New NotesSession    
   Dim view As NotesView
   Dim dc As NotesDocumentCollection
   Dim db As NotesDatabase
   Dim Doc As NotesDocument
   
   Set db = session.CurrentDatabase
   Set dc = db.UnprocessedDocuments
   Set doc = dc.GetFirstDocument
   
   Dim OK As String   
   Dim nnUser As String
   nnUser = Session.CommonUsername
   
   
   While Not ( doc Is Nothing)
      OK = Inputbox ("Hallo",1)
      If OK <> "" Then
         ergebnis =    makeHistorieneintrag ( doc.UniversalID, nnUser, OK  )
      End If
      
      Set doc = dc.GetNextDocument(doc)
   Wend
   

Skript aus dem Frontend

   Dim uiws As New NotesUIWorkspace
   Dim uidoc As NotesUIDocument
   Dim session As New NotesSession
   Dim doc As NotesDocument
   
   Set uidoc = uiws.CurrentDocument
   Set doc = uidoc.Document
   
   Dim nnUser As String
   nnUser = Session.CommonUsername
   Dim OK As String
   OK = Inputbox ("Hallo",1)
   If OK <> "" Then
      ergebnis =    makeHistorieneintrag ( doc.UniversalID, nnUser, OK  )
   End If
End Sub


Identische Funktion für Beide :

Function makeHistorieneintrag ( unid As String, User As String, Text As String) As Integer
   
   Set HEUTE = New NotesDateTime( "Heute" ) ' As String   
   Dim Eintrag As String
   Dim item As NotesItem
   
   Eintrag = Cstr(Heute.localtime) & " " & User & " " & Trim$(Text)
   Dim session As NotesSession
   Dim db As NotesDatabase
   Dim doc As NotesDocument
   Set session = New NotesSession
   Set db  = session.CurrentDatabase
   Set doc = db.GetDocumentByUNID(unid)
   
   
   
   If Not (doc Is Nothing) Then
      
      If doc.~$Historie(0) = "" Then
         Print "Neu : " & Eintrag
         doc.~$Historie = Eintrag
         Call doc.save(True,True)
      Else
         Print "Zusatz : " & Eintrag
         doc.~$Historie =  Arrayappend( doc.~$Historie, Eintrag )         
         Call doc.Save(True, False)
      End If
      
   End If
   
End Function

ata:
... da bin ich aber beruhigt, denn ich verwende den Arrayappend in der von dir beschriebenen Weise - die Korrektur von Axel war maßgebend...

ata  ;D

Navigation

[0] Themen-Index

[#] Nächste Seite

[*] Vorherige Sete

Zur normalen Ansicht wechseln