Das Notes Forum

Domino 9 und frühere Versionen => Entwicklung => Thema gestartet von: OCS am 03.03.05 - 16:18:14

Titel: antwortdokument als uidoc aus dem backend erstellen?
Beitrag von: OCS am 03.03.05 - 16:18:14
hi leute,
habe eine db, von der aus ich in eine andere db gehe und mir ein dokument gezielt anhand der unid suche, funktioniert alles soweit.... hab ich die möglichkeit, jetz ein antwortdokument von diesem dokument im frontend zu erstellen? hoffe das war verständlich...

gruß

björn

zum besseren verständnis, der quelltext bis jetzt...


Sub Initialize
   Dim uidoc As notesuidocument
   Dim session As notessession
   Set session = New notessession
   Dim item As notesitem
   Dim workspace As notesuiworkspace
   Dim rtitem As notesrichtextitem
   Dim db As NotesDatabase
   Set workspace = New notesuiworkspace
   Dim collection As NotesDocumentCollection
   Dim doc As NotesDocument
   Dim currentdoc As NotesDocument
   Dim problem As String
   Set uidoc = workspace.currentdocument
   Dim temp As String
   Dim view As notesview
   Dim aktivid As String
   Dim aktivdoc As notesuidocument
   Dim newdoc As notesuidocument
   
   
   Set currentdoc = uidoc.Document 
   Call uidoc.save   
   aktivid = uidoc.fieldgettext("aktiv_id")
   
   Call uidoc.save
   'Call uidoc.close
   
   
   Set db = session.Getdatabase("SCHMITT01/SCHMITT", "aktiv\aktiv003.nsf", False)
   Set view = db.getview ("ViewActionsUNID")
   Call view.Refresh
   Set collection = view.getalldocumentsbykey(aktivid)
   Set doc = collection.GetFirstDocument()
   Print collection.count
   
   
   und hier will ich ein antwortdokument auf doc erstellen!!!
   
End Sub
Titel: Re: antwortdokument als uidoc aus dem backend erstellen?
Beitrag von: Marinero Atlántico am 03.03.05 - 16:42:29
In Pseudocode (heisst: die Methoden mögen anders heissen, aber im Groben sollte es stimmen)
Code
Dim docResp as yourResponse
set  docResp = db.createDocument
docResp.makeResponse(doc)

' wichtig. Vergisst man schnell: 
docResp.save true, false
Titel: Re: antwortdokument als uidoc aus dem backend erstellen?
Beitrag von: OCS am 03.03.05 - 16:50:49
sollte dann wohl jetzt so aussehen:

Sub Initialize
   Dim uidoc As notesuidocument
   Dim session As notessession
   Set session = New notessession
   Dim item As notesitem
   Dim workspace As notesuiworkspace
   Dim rtitem As notesrichtextitem
   Dim db As NotesDatabase
   Set workspace = New notesuiworkspace
   Dim collection As NotesDocumentCollection
   Dim doc As NotesDocument
   Dim currentdoc As NotesDocument
   Dim problem As String
   Set uidoc = workspace.currentdocument
   Dim temp As String
   Dim view As notesview
   Dim aktivid As String
   Dim aktivdoc As notesuidocument
   Dim newdoc As notesdocument
   
   
   Set currentdoc = uidoc.Document 
   Call uidoc.save   
   aktivid = uidoc.fieldgettext("aktiv_id")
   
   Call uidoc.save
   'Call uidoc.close
   
   
   Set db = session.Getdatabase("SCHMITT01/SCHMITT", "aktiv\aktiv003.nsf", False)
   Set view = db.getview ("ViewActionsUNID")
   Call view.Refresh
   Set collection = view.getalldocumentsbykey(aktivid)
   Set doc = collection.GetFirstDocument()
   Print collection.count
   
   Set  newdoc = db.createDocument
   
   Call newdoc.MakeResponse( doc )
   Call newdoc.Save( False, False )
   

  workspace.EditDocument True,newdoc
   

...


bekomme aber den fehler vorgabemaske nicht gefunden!!!
Titel: Re: antwortdokument als uidoc aus dem backend erstellen?
Beitrag von: OCS am 03.03.05 - 16:54:49
k, hab noch

   newdoc.Form = "aktion"


eingafügt, jetz gehts.... leider übernimmt er keine daten aus dem mutterdokument!!!! an was könte das liegen??
Titel: Re: antwortdokument als uidoc aus dem backend erstellen?
Beitrag von: koehlerbv am 03.03.05 - 17:06:10
Wenn Du im Backend arbeitest, werden natürlich keine Vorgabewerte übernommen. Da ist Handarbeit angesagt.

Bernhard
Titel: Re: antwortdokument als uidoc aus dem backend erstellen?
Beitrag von: Thomas Schulte am 03.03.05 - 17:06:59
wollt ich auch gerade sagen
Titel: Re: antwortdokument als uidoc aus dem backend erstellen?
Beitrag von: OCS am 03.03.05 - 17:23:41
wollt ich nur wissen :-) danke!
Titel: Re: antwortdokument als uidoc aus dem backend erstellen?
Beitrag von: OCS am 03.03.05 - 17:58:27
noch was anderes, wie kan ich einen string in einen variant schreiben?
Titel: Re: antwortdokument als uidoc aus dem backend erstellen?
Beitrag von: koehlerbv am 03.03.05 - 18:00:37
Wie meinen ? Variant ist die Hure der LS-Programmierer und ist offen für fast alles  ;D
Titel: Re: antwortdokument als uidoc aus dem backend erstellen?
Beitrag von: OCS am 03.03.05 - 18:03:03
lol, müsste doch eigentlich mit

variant = string gehen, oder?   da krieg ich nen fehler

set variant = string ? da krieg ich auch nen fehler!
Titel: Re: antwortdokument als uidoc aus dem backend erstellen?
Beitrag von: koehlerbv am 03.03.05 - 18:07:26
Bitte opfere Grossbuchstaben an den richtigen Stellen für uns - und gib' aussagekräftige Fehlermeldungen an und Code, wo notwendig.

Bernhard
Titel: Re: antwortdokument als uidoc aus dem backend erstellen?
Beitrag von: OCS am 03.03.05 - 18:10:50
Schuldigung, das mit nur klein schreiben ist ne schlechte Angewohnheit! Also, ich leser mit den CommonUserName aus der Session in einen String aus und möchte diesen String jetzt irgendwie in eine Variable vom Datentyp Variant kopieren.
Titel: Re: antwortdokument als uidoc aus dem backend erstellen?
Beitrag von: koehlerbv am 03.03.05 - 18:13:38
Das sollte kein Problem darstellen. Code ?
Titel: Re: antwortdokument als uidoc aus dem backend erstellen?
Beitrag von: OCS am 03.03.05 - 18:23:03
Sub Initialize
   Dim uidoc As notesuidocument
   Dim session As notessession
   Set session = New notessession
   Dim item As notesitem
   Dim workspace As notesuiworkspace
   Dim rtitem As notesrichtextitem
   Dim db As NotesDatabase
   Set workspace = New notesuiworkspace
   Dim collection As NotesDocumentCollection
   Dim doc As NotesDocument
   Dim currentdoc As NotesDocument
   Dim problem As String
   Set uidoc = workspace.currentdocument
   Dim temp As String
   Dim view As notesview
   Dim aktivid As String
   Dim aktivdoc As notesuidocument
   Dim newdoc As notesdocument
   Dim KDNR As notesitem
   Dim name1 As notesitem
   Dim AUFPOS As notesitem
   Dim CLART As notesitem
   Dim CLID As notesitem
   Dim CPART As notesitem
   Dim CPBEZ As notesitem
   Dim CPENDE As notesitem
   Dim CPOCSSB As notesitem
   Dim CPREADER As notesitem
   Dim CPSTATUS As notesitem
   Dim IPSS As notesitem
   Dim Kunde As notesitem
   Dim aufnr As notesitem
   Dim user As String
   
   
   Set currentdoc = uidoc.Document 
   Call uidoc.save   
   aktivid = uidoc.fieldgettext("aktiv_id")
   
   Call uidoc.save
   'Call uidoc.close
   
   
   Set db = session.Getdatabase("SCHMITT01/SCHMITT", "aktiv\aktiv003.nsf", False)
   Set view = db.getview ("ViewActionsUNID")
   Call view.Refresh
   Set collection = view.getalldocumentsbykey(aktivid)
   Set doc = collection.GetFirstDocument()
   Print collection.count
   
   -->      user = session.CommonUserName      Stimmt noch
   
   
   Set NAME1 = doc.getfirstitem("NAME1")
   Set KDNR = doc.Getfirstitem( "KDNR" )
   Set AUFNR = doc.Getfirstitem( "AUFNR" )
   Set AUFPOS = doc.Getfirstitem( "AUFPOS" )
   Set CLART = doc.Getfirstitem( "CLART" )
   Set CLID = doc.Getfirstitem( "CLID" )
   Set CPART = doc.Getfirstitem( "CPART" )
   Set CPBEZ = doc.Getfirstitem( "CPBEZ" )
   Set CPENDE = doc.Getfirstitem( "CPENDE" )

   Set CPOCSSB = user   --> Das lässt schon der Designer nicht zu!!!


   Set CPREADER = doc.Getfirstitem( "CPREADER" )
   Set CPSTATUS = doc.Getfirstitem( "CPSTATUS" )
   Set IPSS = doc.Getfirstitem( "IPSS" )
   Set KUNDE = doc.Getfirstitem( "KUNDE" )
   
   [
   Set  newdoc = db.createDocument
   
   Call newdoc.MakeResponse( doc )
   newdoc.Form = "aktion"
   Call newdoc.save (True, True)
   
   Set KDNR = newdoc.ReplaceitemValue( "KDNR", KDNR )
   Set NAME1 = newdoc.ReplaceitemValue( "NAME1", NAME1 )
   Set AUFNR = newdoc.ReplaceitemValue( "AUFNR", AUFNR )
   Set AUFPOS = newdoc.ReplaceitemValue( "AUFPOS", AUFPOS )
   Set CLART = newdoc.ReplaceitemValue( "CLART", CLART )
   Set CLID  = newdoc.ReplaceitemValue( "CLID", CLID )
   Set CPART = newdoc.ReplaceitemValue( "CPART", CPART )
   Set CPBEZ  = newdoc.ReplaceitemValue( "CPBEZ ", CPBEZ  )
   Set CPENDE = newdoc.ReplaceitemValue( "CPENDE", CPENDE )
   Set CPOCSSB = newdoc.ReplaceitemValue( "CPOCSSB", CPOCSSB )
   Set CPREADER = newdoc.ReplaceitemValue( "CPREADER", CPREADER )
   Set CPSTATUS = newdoc.ReplaceitemValue( "CPSTATUS", CPSTATUS )
   Set IPSS = newdoc.ReplaceitemValue( "IPSS", IPSS )
   Set KUNDE = newdoc.ReplaceitemValue( "KUNDE", KUNDE )
   
   
   Call newdoc.save (True, True)
   workspace.EditDocument True,newdoc
'Call newdoc.Save( False, False )
   'workspace.EditDocument True,newdoc
   
' wichtig. Vergisst man schnell:
   
   
   '
   
End Sub
Titel: Re: antwortdokument als uidoc aus dem backend erstellen?
Beitrag von: Semeaphoros am 03.03.05 - 18:26:26
Zitat
Set CPOCSSB = user   --> Das lässt schon der Designer nicht zu!!!

Logisch, jedes Objekt muss mit New instanziiert werden, es sei denn, man bekommt das von einem anderen Objekt erledigt. Hier also zuerst:

Set CPOCSSB = New NotesItem

Das steht in der Hilfe unter NotesItem und das sollte man unbedingt mal nachgelesen haben.
Titel: Re: antwortdokument als uidoc aus dem backend erstellen?
Beitrag von: koehlerbv am 03.03.05 - 18:29:35
Jo, und warum redest Du von Variant, wenn Du einem NotesItem-Objekt einen String zuweisen willst ?
Titel: Re: antwortdokument als uidoc aus dem backend erstellen?
Beitrag von: Marinero Atlántico am 03.03.05 - 18:32:52
Wie Bernhard.

Mal so allgemein:

Ich würd an deiner Stelle grundsätzlich die ganzen zu kopierenden Items aus dem Hauptdokument erzeugen.
Wie du ja schon gemacht hast.
Code
Set NAME1 = doc.getfirstitem("NAME1")
   Set KDNR = doc.Getfirstitem( "KDNR" )
   Set AUFNR = doc.Getfirstitem( "AUFNR" )
   Set AUFPOS = doc.Getfirstitem( "AUFPOS" )
   Set CLART = doc.Getfirstitem( "CLART" )
   Set CLID = doc.Getfirstitem( "CLID" )
   Set CPART = doc.Getfirstitem( "CPART" )
   Set CPBEZ = doc.Getfirstitem( "CPBEZ" )
   Set CPENDE = doc.Getfirstitem( "CPENDE" )

Und dann mit NotesItem.copyItemToDocument(newDoc, "neuerItemName") arbeiten (echt guter Tipp, wie ich finde, also in keinem Fall überlesen).

In der Praxis sähe das dann etwa so aus:
Code
NAME1.copyItemToDocument(newDoc, "NAME1")

Die Namen der Items für die zu kopierenden Dokumente in dem alten Dokument und dem neuen Dokument in je einem Array schreiben. Das gleiche mit den Item-Objekten selbst. Oder in 1 Array aus Structs (letzeres ist wohl besser). Das Struct hat dann 2 String-Member (feldNameNew und feldNameAlt sowie 1 NotesItem).
Das würd ich aber morgen machen.

Axel
Titel: Re: antwortdokument als uidoc aus dem backend erstellen?
Beitrag von: OCS am 03.03.05 - 18:36:48
Sorry, verpeilt! Es geht aber leider  so auch nicht. bekomme beim "Set CPOCSSB = New NotesItem" die Fehlermeldung : Missing Argument to constructor for Notesitem.
Titel: Re: antwortdokument als uidoc aus dem backend erstellen?
Beitrag von: Glombi am 03.03.05 - 18:46:12
Dann siehe doch bitte mal endlich in der Designer Hilfe nach !

Dort steht
Set notesItem = New NotesItem( notesDocument, name$, value  [, specialType% ] )

Parameters
notesDocument
The document on which to create the item.
name$
String. The name of the new item.
value
The value to assign to the new item. The data type of value determines the type of item that Notes creates:
   Data type of value   Resulting notesItem
   String   Text item containing the value (if specialType% is used, may be Names, Readers, or Authors)
   Array of String   Text item containing each element of the value (if specialType% is used, may be Names, Readers, or Authors)
   Long, Integer, Double, Single, or Currency   Number item containing the value
   Array of Long, Integer, Double, Single, or Currency   Number item containing each element of the value
   Variant of type DATE or NotesDateTime   Date-time item containing the value
   Array of Variant of type DATE or array of NotesDateTime   Date-time item containing each element of the value
   NotesItem   Item whose data type matches the NotesItem type and whose value(s) match the NotesItem value(s)
Type conversion occurs as necessary. For example, floating-point numeric items are double precision so a value of type Single is converted to Double prior to storage.
specialType%
Optional. Constant of type integer. Indicates if a text item should be of type Names, Readers, or Authors. Must be one of the following constants: NAMES, READERS, or AUTHORS. To use specialType%, the value parameter must be a string or array of strings.

Andreas
Titel: Re: antwortdokument als uidoc aus dem backend erstellen?
Beitrag von: Marinero Atlántico am 03.03.05 - 18:56:50
Code
set  CPOCSSB = new NotesItem (doc, "CPOCSSB", user)
[...]
Call newdoc.MakeResponse( doc )
   newdoc.Form = "aktion"
 NAME1.copyItemToDocument(newDoc, "NAME1")
[...] der ganze Rest so ähnlich. 
   
   Call newdoc.save (True, True)
   workspace.EditDocument True,newdoc
'Call newdoc.Save( False, False )
   'workspace.EditDocument True,newdoc
   
' wichtig. Vergisst man schnell:
   
End Sub
und das mit den Arrays ist ne gute Idee.
Und das mit den structs noch eine bessere.