Domino 9 und frühere Versionen > ND8: Entwicklung

Probleme mit Dialogboy

(1/3) > >>

zapfbay:
Hallo zusammen,

ich habe von einem Kollegen vor einiger Zeit den Bereich Notes in der Firma übernommen und wurde damit ins eiskalte Wasser geworfen. Vieles konnte ich schon lösen, aber jetzt bin ich bei einem Problem an meine Grenzen gestoßen. Hoffe Ihr könnt mir helfen.

Ich habe ein "Hauptfenster", von dort wird eine Dialogbox ausgewählt, in der der User in einer Ansicht eine Auswahl treffen kann. Bisher wurde dort nur Text ausgewählt und an das Hauptfenster zurückgeschreiben. Jetzt habe ich die Ansicht um das Feld fdArtikelPreis erweitert. Bei Auswahl soll jetzt dieser Preis ebenfalls zurück ins Hauptfenster geschreiben werden... Aber irgendwie komme ich mit dem vorhandenen Quelltext nicht klar. Könnt Ihr mir da irgendwie helfen?! Bin recht am verzweifeln...

Function ArtikelZugriff(sZeile As String, sKategorie As String) As Integer
   Dim ws As New NotesUiWorkspace
   Dim session As New NotesSession
   Dim db As NotesDatabase
   Dim note As NotesDocument
   Dim uiNote As NotesUIDocument
   Dim uiDoc As NotesUIDocument
   Dim xArray As Variant
   Dim sText As String
   Dim sView As String
   Dim oView As NotesView
   Dim notesDoc As NotesDocument
   Dim notesDoc2 As NotesDocument
   Dim sArtText As String
   Dim rtitem As NotesRichTextItem
   Dim rtitem2 As NotesRichTextItem
   Dim nItem As Notesitem
   Dim newdoc As NotesDocument
   Dim sField As String
   Dim item As NotesItem
   
   Set UiNote = ws.CurrentDocument
   sFirma = UiNote.FieldGetText("fdProduktFirma")
   If sFirma = "" Then
      sFirma = "ZAPF"
   End If
   
   sField = "fdArtikel_" + sZeile
   
   sView = "viwArtikel"
   
   If sFirma = "ZAPF" Then
      sView = "viwArtikelZ"
   Else
      sView = "viwArtikelK"
   End If
   
   
   ArtikelZugriff = 0
   
   Set db = session.CurrentDatabase
   Set oView = db.GetView("viwArt")
   If sView = "viwArtikelZ" Or sView = "viwArtikelK" Then
      xArray = ws.picklistStrings(PICKLIST_CUSTOM, False, db.server, db.FilePath, sView, _
      sKategorie, "Bitte wählen Sie einen Artikel aus", 5, "")
   Else
      xArray = ws.picklistStrings(PICKLIST_CUSTOM, False, db.server, db.FilePath, sView, _
      sKategorie, "Bitte wählen Sie einen Artikel aus", 5, sFirma)
   End If
   
   If Isempty(xArray) Then Exit Function
   
   Set NotesDoc = oView.GetDocumentByKey(xArray(0))
   
   If Notesdoc Is Nothing Then Exit Function
   
   Set item = Notesdoc.GetFirstItem("fdArtikelHinweis")
   Set rtitem = Notesdoc.GetFirstItem("fdArtikelTextRTF")
   Set rtitem2 = Notesdoc.GetFirstItem("fdTechBeschreibung")
   If rtitem2.text <> "" Then
      Call rtitem.AddNewLine(1)
      Call rtitem.AppendRTItem(rtitem2)
   End If
   
   Set NotesDoc2 = db.GetProfileDocument("Artikelauswahl", session.CommonUserName)
   Call NotesDoc2.removeItem("fdArtikelTextRTF")
   Call NotesDoc2.removeItem("fdArtikelHinweis")
'   Set NotesDoc2 = db.CreateDocument
   Call NotesDoc2.CopyItem( rtitem, "fdArtikelTextRTF" )
   Call NotesDoc2.CopyItem( item, "fdArtikelHinweis" )
   
   
   success = ws.Dialogbox("faRTF", True, True, False, False, False, False, "Artikelauswahl", NotesDoc2, True, False)
'   Call NotesDoc2.Remove(True)
   
   Call uinote.Gotofield(sField)
   Call UiNote.Paste
'   Call UiNote.FieldSetText("fdPos_"+sZeile, sZeile)
   
   
   Call NotesDoc2.Save( False, True )
   
   If NotesDoc.FieldGetText("fdPreisl_" + sZeile) = ""  Then
      Set NotesDoc2 = NotesDoc.Document
      Call NotesDoc.ReplaceItemValue("fdPreis_" + sZeile, NotesDoc2.fdPreis(0))
      Call NotesDoc.Save(False, True)
      Call NotesDoc.Reload()
      Call NotesDoc.Refresh()
   End If
   
   
   ArtikelZugriff = 1
End Function

koehlerbv:
Statt PicklistStrings solltest Du eine PicklistCollection verwenden. Dann stehen Dir alle Items des ausgewählten Dokuments zur Verfügung.

Bernhard

zapfbay:
Danke für die Info.

Habe meinen Quelltext jetzt mal ein bisschen geändert:

Aber momentan wird das Ergebnis ja noch allgemein in sField kopiert, was ja für den Preis das falsche Feld ist. Wie teile ich das am Geschicktesten auf, dass er den Preis in sField2 schreibt und auch richtig kopiert? Muss ich da das Ganze mit RemoveItem und CopyItem auch für den Preis machen? Sorry, wenn ich vielleicht etwas dumm frage, aber ich steh bei dem Thema echt noch auf dem Schlauch.

Function ArtikelZugriff(sZeile As String, sKategorie As String) As Integer
   Dim ws As New NotesUiWorkspace
   Dim session As New NotesSession
   Dim db As NotesDatabase
   Dim note As NotesDocument
   Dim uiNote As NotesUIDocument
   Dim uiDoc As NotesUIDocument
   Dim xArray As Variant
   Dim sText As String
   Dim sView As String
   Dim oView As NotesView
   Dim notesDoc As NotesDocument
   Dim notesDoc2 As NotesDocument
   Dim sArtText As String
   Dim rtitem As NotesRichTextItem
   Dim rtitem2 As NotesRichTextItem
   Dim nItem As Notesitem
   Dim newdoc As NotesDocument
   Dim sField As String
   Dim sField2 As String   'neu
   Dim item As NotesItem
   Dim preisitem As NotesItem   'neu
  
   Set UiNote = ws.CurrentDocument
   sFirma = UiNote.FieldGetText("fdProduktFirma")
   If sFirma = "" Then
      sFirma = "ZAPF"
   End If
  
   sField = "fdArtikel_" + sZeile
   sField = "fdPreis_" + sZeile
  
   sView = "viwArtikel"
  
   If sFirma = "ZAPF" Then
      sView = "viwArtikelZ"
   Else
      sView = "viwArtikelK"
   End If
  
  
   ArtikelZugriff = 0
  
   Set db = session.CurrentDatabase
   Set oView = db.GetView("viwArt")
   If sView = "viwArtikelZ" Or sView = "viwArtikelK" Then
      xArray = ws.picklistCollection(PICKLIST_CUSTOM, False, db.server, db.FilePath, sView, _
      sKategorie, "Bitte wählen Sie einen Artikel aus", 5, "")
   Else
      xArray = ws.picklistCollection(PICKLIST_CUSTOM, False, db.server, db.FilePath, sView, _
      sKategorie, "Bitte wählen Sie einen Artikel aus", 5, sFirma)
   End If
  
   If Isempty(xArray) Then Exit Function
  
   Set NotesDoc = oView.GetDocumentByKey(xArray(0))
  
   If Notesdoc Is Nothing Then Exit Function
  
   Set item = Notesdoc.GetFirstItem("fdArtikelHinweis")
   Set rtitem = Notesdoc.GetFirstItem("fdArtikelTextRTF")
   Set rtitem2 = Notesdoc.GetFirstItem("fdTechBeschreibung")
   If rtitem2.text <> "" Then
      Call rtitem.AddNewLine(1)
      Call rtitem.AppendRTItem(rtitem2)
   End If

  Set preisitem = Notesdoc.GetFirstItem("fdArtikelPreis")
  
   Set NotesDoc2 = db.GetProfileDocument("Artikelauswahl", session.CommonUserName)
   Call NotesDoc2.removeItem("fdArtikelTextRTF")
   Call NotesDoc2.removeItem("fdArtikelHinweis")
'   Set NotesDoc2 = db.CreateDocument
   Call NotesDoc2.CopyItem( rtitem, "fdArtikelTextRTF" )
   Call NotesDoc2.CopyItem( item, "fdArtikelHinweis" )
  
  
   success = ws.Dialogbox("faRTF", True, True, False, False, False, False, "Artikelauswahl", NotesDoc2, True, False)
'   Call NotesDoc2.Remove(True)
  
   Call uinote.Gotofield(sField)
   Call UiNote.Paste
'   Call UiNote.FieldSetText("fdPos_"+sZeile, sZeile)
  
  
   Call NotesDoc2.Save( False, True )
  
   If NotesDoc.FieldGetText("fdPreisl_" + sZeile) = ""  Then
      Set NotesDoc2 = NotesDoc.Document
      Call NotesDoc.ReplaceItemValue("fdPreis_" + sZeile, NotesDoc2.fdPreis(0))
      Call NotesDoc.Save(False, True)
      Call NotesDoc.Reload()
      Call NotesDoc.Refresh()
   End If
  
  
   ArtikelZugriff = 1

End Function

DAU-in:
Call NotesDoc.Reload()
Call NotesDoc.Refresh()

bist du sicher, dass das korrekt ist?
NotesDoc ist doch ein BackendDokument?
Was sagt denn der Debugger?
Und hast du Option declare eingeschaltet?
ansonsten: copyItem, replaceItemValue oder den ItemInhaltdirekt zuweisen:
docNeu.feldname = docAlt.feldnameAlt(0)

zapfbay:
Oh Mist, ich sehe gerade, ich habe da wohl einen Teil des Quelltextes eingefügt, bei dem ich selbst schon rumgebastelt habe...

Habe den Quelltext jetzt mal ein bisschen geändert, bekomme jetzt aber in Notes folgende Fehlermeldung: Falscher Datentyp in Methode RunStkCoerceVal: STRING wurde gefunden, NULL wurde erwartet???!?!?!

@DAU-In:
ich gebe Dir Recht, das mit dem Reload, Refresh war Mist. Ich hab da nur was getestet und versehentlich mit gepostet.
- Option Declare ist eingeschaltet.

Function ArtikelZugriff(sZeile As String, sKategorie As String) As Integer
   Dim ws As New NotesUiWorkspace
   Dim session As New NotesSession
   Dim db As NotesDatabase
   Dim note As NotesDocument
   Dim uiNote As NotesUIDocument
   Dim uiDoc As NotesUIDocument
   Dim xArray As Variant
   Dim sText As String
   Dim sView As String
   Dim oView As NotesView
   Dim notesDoc As NotesDocument
   Dim notesDoc2 As NotesDocument
   Dim sArtText As String
   Dim rtitem As NotesRichTextItem
   Dim rtitem2 As NotesRichTextItem
   Dim nItem As Notesitem
   Dim newdoc As NotesDocument
   Dim sField As String
   Dim item As NotesItem
   Dim sPreis As String
   
   Set UiNote = ws.CurrentDocument
   sFirma = UiNote.FieldGetText("fdProduktFirma")
   If sFirma = "" Then
      sFirma = "ZAPF"
   End If
   
   sField = "fdArtikel_" + sZeile
   
   sView = "viwArtikel"
   
   If sFirma = "ZAPF" Then
      sView = "viwArtikelZ"
   Else
      sView = "viwArtikelK"
   End If
   
   
   ArtikelZugriff = 0
   
   Set db = session.CurrentDatabase
   Set oView = db.GetView("viwArt")
   If sView = "viwArtikelZ" Or sView = "viwArtikelK" Then
      xArray = ws.picklistStrings(PICKLIST_CUSTOM, False, db.server, db.FilePath, sView, _
      sKategorie, "Bitte wählen Sie einen Artikel aus", 5, "")
   Else
      xArray = ws.picklistStrings(PICKLIST_CUSTOM, False, db.server, db.FilePath, sView, _
      sKategorie, "Bitte wählen Sie einen Artikel aus", 5, sFirma)
   End If
   
   If Isempty(xArray) Then Exit Function
   
   Set NotesDoc = oView.GetDocumentByKey(xArray(0))
   
   If Notesdoc Is Nothing Then Exit Function
   
   Set item = Notesdoc.GetFirstItem("fdArtikelHinweis")
   Set rtitem = Notesdoc.GetFirstItem("fdArtikelTextRTF")
   Set rtitem2 = Notesdoc.GetFirstItem("fdTechBeschreibung")
   If rtitem2.text <> "" Then
      Call rtitem.AddNewLine(1)
      Call rtitem.AppendRTItem(rtitem2)
   End If
   
   Set NotesDoc2 = db.GetProfileDocument("Artikelauswahl", session.CommonUserName)
   Call NotesDoc2.removeItem("fdArtikelTextRTF")
   Call NotesDoc2.removeItem("fdArtikelHinweis")
'   Set NotesDoc2 = db.CreateDocument
   Call NotesDoc2.CopyItem( rtitem, "fdArtikelTextRTF" )
   Call NotesDoc2.CopyItem( item, "fdArtikelHinweis" )
   
'Diese Zeile ist für den Fehler verantwortlich - aber warum???
   sPreis = NotesDoc2.FieldGetText("fdArtikelPreis")
   
   
   success = ws.Dialogbox("faRTF", True, True, False, False, False, False, "Artikelauswahl", NotesDoc2, True, False)
'   Call NotesDoc2.Remove(True)
   
   Call uinote.Gotofield(sField)
   Call UiNote.Paste
   
   Call UiNote.FieldSetText("fdPreis_"+sZeile, sPreis)
   
   ArtikelZugriff = 1
End Function

Navigation

[0] Themen-Index

[#] Nächste Seite

Zur normalen Ansicht wechseln