Autor Thema: Document link für Dokumente einer anderen DB erzeugen  (Gelesen 3830 mal)

Offline js84

  • Junior Mitglied
  • **
  • Beiträge: 90
  • Geschlecht: Weiblich
Hallo @all,

ich möchte aus einer Form auf eine andere DB zugreifen. Aus dieser DB möchte ich Documente haben die ein bestimmtes Kriterium erfülllen (getAllDocumentsBykey) soweit so gut. In meiner Form möchte ich jetzt aber für die "matchenden" Dokumente ein Documentlink erzeugen. Dazu nachfolgender Code. Ich bekomme allerdings folgende Fehlermeldung:
"Couldn't get default View id for database".

Kann mir jemand helfen?

Dim rtitem2 As NotesRichTextItem
   Dim view As NotesView
   Dim ndc As NotesDocumentCollection
   Dim uidoc As NotesUIDocument
   Dim ws As New NotesUIWorkspace
   Dim db2 As NotesDatabase
   
   Dim doc As NotesDocument
   Dim doc_cur As NotesDocument
   
   Dim customer_in_pmr As String
   Dim var As Variant
   Dim pmr_nr As Variant
   
   Set db2= New NotesDatabase(servername,pfad zur ZielDB)   
   Set uidoc=ws.CurrentDocument
   Set doc_cur=uidoc.Document
   Set view=db2.GetView(viewname)
   
   
   Set rtitem2=doc_cur.GetFirstItem("pmr_doc_link")
   customer_in_pmr=uidoc.FieldGetText("Customer_in_PMR_DB")
   
   Set ndc=view.GetAllDocumentsByKey(customer_in_pmr,True)
   
   Set doc=ndc.GetFirstDocument()
   If ndc.Count<1 Then
      Msgbox "no pmrs"
   Else
      While Not doc Is Nothing
         pmr_nr=doc.GetItemValue("PMR")
         Set var = doc_cur.GetFirstItem("pmr_doc_link")
         
         
         Set doc = ndc.GetNextDocument ( doc )
      Wend
   End If
   
   
   
   


MfG Jana

Offline Axel

  • Moderator
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 8.658
  • Geschlecht: Männlich
  • It's not a bug, it's Notes
Re: Document link für Dokumente einer anderen DB erzeugen
« Antwort #1 am: 07.06.05 - 16:08:02 »
Hi,

hast du in den Datenbanken eine Vorgabeansicht definiert?

Das findest du in den Ansichten-Eigenschaften als Option "Vorgabe beim ersten Öffnen der Datenbank". Im Designer wird diese Ansicht dann mit einem blauen Pfeil gekennzeichnet.


Axel

Ohne Computer wären wir noch lange nicht hinterm Mond!

Offline js84

  • Junior Mitglied
  • **
  • Beiträge: 90
  • Geschlecht: Weiblich
Re: Document link für Dokumente einer anderen DB erzeugen
« Antwort #2 am: 07.06.05 - 16:16:54 »
Hi Axel,

also in der DB, aus der ich das ganze "steuere" ist eine Vorgabeansicht definiert in meiner Zieldb allerdings nicht. Das Problem ist, dass ich an der Zieldb nix ändern darf.

MfG
Jana

Offline koehlerbv

  • Moderator
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 20.460
  • Geschlecht: Männlich
Re: Document link für Dokumente einer anderen DB erzeugen
« Antwort #3 am: 07.06.05 - 16:34:24 »
Eine DB ohne Vorgabeansicht ist schlecht - da sind weitere Probleme vorprogrammiert.

In welcher Zeile bekommst Du eigentlich genannte Fehlermeldung ? Und wo in Deinem Code dealst Du mit DocLinks ? Warum verwendest Du ein Variant als Variable für ein NotesItem ?

Bernhard

Offline js84

  • Junior Mitglied
  • **
  • Beiträge: 90
  • Geschlecht: Weiblich
Re: Document link für Dokumente einer anderen DB erzeugen
« Antwort #4 am: 07.06.05 - 16:51:19 »
Hi,

sorry ich hab da ein Teil vergessen bzw. falsch gepostet :-[


also hier noch  mal das richtige, die Fehlermeldung kommt bei "Call rtitem2.AppendDocLink(doc,"")"


Dim rtitem2 As NotesRichTextItem
   Dim view As NotesView
   Dim ndc As NotesDocumentCollection
   Dim uidoc As NotesUIDocument
   Dim ws As New NotesUIWorkspace
   Dim db2 As NotesDatabase
   
   Dim doc As NotesDocument
   Dim doc_cur As NotesDocument
   
   Dim customer_in_pmr As String
   Dim var As Variant
   Dim pmr_nr As Variant
   
   Set db2= New NotesDatabase(servername,Pfad)   
   Set uidoc=ws.CurrentDocument
   Set doc_cur=uidoc.Document
   Set view=db2.GetView(viewname)
   
   
   Set rtitem2=doc_cur.GetFirstItem("pmr_doc_link")
   customer_in_pmr=uidoc.FieldGetText("Customer_in_PMR_DB")
   
   Set ndc=view.GetAllDocumentsByKey(customer_in_pmr,True)
   
   Set doc=ndc.GetFirstDocument()
   If ndc.Count<1 Then
      Msgbox "no pmrs"
   Else
      While Not doc Is Nothing
         pmr_nr=doc.GetItemValue("PMR")
         Call rtitem2.AppendDocLink(doc,"")
         
      Wend
   End If
   
   
   Tschuldigung für die Verwirrung, die ich gestifftet habe
   

Offline koehlerbv

  • Moderator
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 20.460
  • Geschlecht: Männlich
Re: Document link für Dokumente einer anderen DB erzeugen
« Antwort #5 am: 07.06.05 - 16:59:41 »
Jana, der einfachste Weg zur Problemlösung wäre, die Herren der Ziel-DB zu veranlassen, dort eine Vorgabeansicht zu definieren.

Alternativ kann ich Dir zwei Methoden nennen, um den DocLink "more individually" zu kreieren. Inwieweit dies bei Dir funktioniert, kann ich nicht beurteilen. Achtung: Methode 1 basiert auf einer undokumentierten Methode der NotesRichTextItem class !

HTH,
Bernhard

Variante 1 - NotesRichTextItem.Add LinkByIDs (UNDOKUMENTIERT !)
Zitat
Given replicaID of a database and the UNIDS of a view or document to link to, adds a link to the end of a rich-text item.

Defined In

NotesRichTextItem


Syntax

Call notesRichTextItem.AddLinkByIds( dbReplicaID$, serverHint$, viewUNID$, documentUNID$, comment$ [, HotSpotText$ ])


Parameters

serverHint$

String. ServerName in Canonical or Common format.

viewUNID$

String. UniversalID of the notesview you want to use for opening the document. Use an empty string ("") to create database link if no documentUNID is specified, or to use the default view for opening docLinks.

documentUNID$

String. UniversalID of the document you want to link to. Use an empty string ("") to create a view Link or database Link.

comment$

String. The text that appears when a user presses and holds the mouse pointer over the link.

HotSpotText$

Optional. String. If supplied, the HotSpotText will appear in the RichTextItem as boxed text which can be clicked on with the mouse to follow the link. In this case, no other token appears in the text.

Quelle: Davy Vanherbergen
05 Aug 2002

Variante 2 - Dealing with a NDL file:
Zitat
Sub Click(Source As Button)

                   'The following piece of code can be pasted in the click event of a button. 
                   'It demonstrates how you can create a database link or a view link using
                   'LotusScript.

                   'The e.g. below sends a view link to the People view in the
                   'local Names & Address book.
                   Dim session As New NotesSession
                   Dim db As NotesDatabase
                   Dim view As NotesView
                   Dim txtDbName As String, txtServerName As String
                   Dim txtDbRepID As String
                   Dim txtViewID As String
                   Dim txtTempFile As String, txtNotesIDToSendTo As String
                   Dim rtitem As NotesRichTextItem
                   Dim note As NotesDocument
                   
                   On Error Goto EH
                   
                   'Initialize variables used in the sub
                   txtServerName = "" 'Local   
                   txtDbName = "names.nsf" 'Db name

                   'Modify the value of this variable before you use this code
                   'A sample Notes memo will be sent to this person
                   txtNotesIDToSendTo = "Siva Ramanathan/Buster/Home Sweet Home"
                   
                   'Open the database which has the view
                   Set db = New NotesDatabase(txtServerName,txtDbName)

                   txtViewName = "People"  'Name of the view in the database
                   
                   If db.IsOpen Then
                        Set view = db.GetView(txtViewName)
                   Else
                        'Db not found or unable to open
                        Msgbox "Error opening database " & txtDbName & _
                          " on server " & txtServerName, 48, "Fatal Error"
                        Exit Sub
                   End If
                   
                   txtDbRepID = db.ReplicaID 'Get the replica id of database
                   txtViewID = view.UniversalID 'Get the view id of the view
                   
                   txtTempFile = "\_temp.ndl" 'Temp file
                   
                   If Not view Is Nothing Then
                        'Construct the magic code and write to file
                        Open txtTempFile For Output As #1
                        Print #1, "Just testing"
                        Print #1, "<NDL>"
                        Print #1, "<REPLICA " & Left$(txtDbRepID,8) & ":" & _
                          Right$(txtDbRepID,8) & ">"
                        Print #1,"<VIEW " &  "OF" & Left$(txtViewID,8) & ":" & _
                          Mid$(txtViewID,9,8) & "-ON" & Mid$(txtViewID,17,8) & ":" & _
                          Right$(txtViewID,8) & ">"
                        Print #1, "<REM>MEOW</REM>"
                        Print #1, "</NDL>"   
                        Close #1
                   Else
                        'View not found!
                        Msgbox "View " & txtViewName & " not found!", 48, "Fatal Error"
                        Exit Sub
                   End If
                   
                   'Create a sample memo to attach the view link
                   Set note = New NotesDocument(db)
                   'Set fields in the memo
                   note.form = "memo"
                   note.SendTo = txtNotesIDToSendTo
                   note.Subject = "I sent you a view link from LotusScript!!"

                   'Now comes the real thing...
                   Set rtitem = New NotesRichTextItem(note,"Body")
                   Call rtitem.AppendText("Double click the attachment and click on " & _
                    "View (or) Launch ==> ")
                   'Attach the temp file (which is actually the link)
                   Call rtitem.EmbedObject(EMBED_ATTACHMENT,"",txtTempFile,"TEST")
                   
                   'Send the message
                   Call note.Send(True)
                   
                   Kill txtTempFile 'Delete the temporary file
                   
                   Exit Sub
                   
              EH:
                   'Handle other run time
                   Beep
                   Msgbox "Error# " & Err & ":" & Error$, 48, "Fatal Error"
                   Print  "Error# " & Err & ":" & Error$
                   Exit Sub
              End Sub

Quelle: Mir unbekannt

Offline js84

  • Junior Mitglied
  • **
  • Beiträge: 90
  • Geschlecht: Weiblich
Re: Document link für Dokumente einer anderen DB erzeugen
« Antwort #6 am: 07.06.05 - 17:03:33 »
Hi,
also ich danke euch erst mal für eure Hilfe, ich werd mal mit den DB Admins reden. :)

Schönen Abend noch

 

Impressum Atnotes.de  -  Powered by Syslords Solutions  -  Datenschutz