Das Notes Forum
Domino 9 und frühere Versionen => ND8: Entwicklung => Thema gestartet von: zapfbay am 11.04.10 - 13:24:41
-
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
-
Statt PicklistStrings solltest Du eine PicklistCollection verwenden. Dann stehen Dir alle Items des ausgewählten Dokuments zur Verfügung.
Bernhard
-
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
-
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)
-
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
-
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???!?!?!
Dann wäre es nicht schlecht, wenn Du zumindest den Code, in dem "RunStkCoerceVal" aufgerufen wird, hier angibst.
'Diese Zeile ist für den Fehler verantwortlich - aber warum???
sPreis = NotesDoc2.FieldGetText("fdArtikelPreis")
Vielleicht weil Du NotesDoc2 als NotesDocument deklarierst, "FieldGetText" aber eine Methode eines NotesUIDocument ist?
-
Ich hab das jetzt mal geändert! Mein letztes großes Problem ist, das "itempreis" jetzt ins Feld "sField2" zu bekommen...
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
Dim item As NotesItem
Dim preisitem As NotesItem
Dim sArtikelPreis As String
Set UiNote = ws.CurrentDocument
sFirma = UiNote.FieldGetText("fdProduktFirma")
If sFirma = "" Then
sFirma = "ZAPF"
End If
sField = "fdArtikel_" + sZeile
sField2 = "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.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")
Set preisitem = Notesdoc.GetFirstItem("fdArtikelPreis")
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")
Call NotesDoc2.removeItem("fdArtikelPreis")
' Set NotesDoc2 = db.CreateDocument
Call NotesDoc2.CopyItem( rtitem, "fdArtikelTextRTF" )
Call NotesDoc2.CopyItem( item, "fdArtikelHinweis" )
Call NotesDoc2.CopyItem( preisitem, "fdArtikelPreis" )
success = ws.Dialogbox("faRTF", True, True, False, False, False, False, "Artikelauswahl", NotesDoc2, True, False)
Call uinote.Gotofield(sField)
Call UiNote.Paste
' Call UiNote.FieldSetText("fdPreis_"+sZeile, sArtikelPreis)
ArtikelZugriff = 1
End Function
-
Ich hab das jetzt mal geändert! Mein letztes großes Problem ist, das "itempreis" jetzt ins Feld "sField2" zu bekommen...
Das wird schwer, nachdem Du keine Zeile hast, in welcher das Feld "sField2" befüllt wird ...
-
Genau das ist mein Problem. Ich weiß nicht, wie ich den Wert "copyItem(preisitem...." in das Feld Field2 bekomme...
mit
Call uinote.Gotofield(sField2)
Call UiNote.Paste
geht's leider nicht - da wird der Inhalt von Item in Field2 geschrieben...
-
welches Item meinst du nun wirklich "preisitem" oder "itempreis", weil du "itempreis" gar nicht hast
und befüllen kannst du es doch relativ einfach
call uinote.document.replaceItemValue("<Feldname>", <wert>)
dann kannst du dir das mit dem gotofield sparen, was eh nicht funktionieren würde, wenn das ein verstecktes feld ist.
-
Danke für Eure Hilfe!
Das war ja einfach... Hab es so ähnlich schon einige Male ausprobiert, aber immer das .document. vergessen und da kam dann immer eine Fehlermeldung mit der ich nichts anfangen konnte.
DANKE nochmal!