Hallo!
Ich steh schon wieder an :-[
Ich hab eine in $$ViewTemplateDefault eingebettete View im Web, bei der man Dokumente auswählen kann.
In den selektierten Dokumenten will ich den Wert eines Feldes setzen.
Ich hab einen Button, der einen Agent aufruft der das machen soll.
Fehler bekomm ich keinen, aber ich hab mir die Anzahl der Dokumente ausgeben lassen, und die ist null ???
Geht UnprocessedDocuments nicht im Web?
Hier der Source des Agenten:
Sub Initialize
Dim s As New NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Dim configView As NotesView
Dim configdoc As NotesDocument
Dim Comment1 As String
Dim Comment2 As String
Dim i As Integer
On Error Goto errHandle
Set db = s.CurrentDatabase
' read Configurationdocument to get Standardcomments
Set configView = db.GetView("($IndexConfiguration)")
Call configView.Refresh()
Set configDoc = configView.getFirstDocument
Comment1 = GetStandardComment1(configDoc)
Comment2 = GetStandardComment2(configDoc)
' Set Comment for selected Docs
Set collection = db.UnprocessedDocuments
Set doc = collection.GetFirstDocument()
i=0
While Not(doc Is Nothing)
i=i+1
If(doc.Flag(0) = "") Then
doc.Comment2(0) = Comment2
Else
doc.Comment1(0) = Comment1
End If
Call doc.Save( False, True )
Set doc = collection.GetNextDocument(doc)
Wend
Print{<h1>}
Print("Prozessed: " + Cstr(i))
Print{</h1>}
errHandle:
End Sub
Vielen vielen Dank - und schönen Feiertag!
lg
Alex
Danke m3, das hat schon viel geholfen!!
Ich hab es ein wenig anders gemacht als im Sample, da ich den Agenten über Web starte, was auch einwandfrei funktioniert.
Allerdings hab ich jetzt Probleme das Feld im Agenten auszulesen. Irgendwie is das immer leer und beim Split haut es ihn dann auf.
Das is der Button in $$ViewTemplateDefault
<input type="button" class="formAction" value="StdComment" target="_blank" onClick="InsertStandardComment()">
Hier der Javascript Teil der bei onClick aufgerufen wird.
TempString is ein verstecktes Feld das Text/Berechnet ist.
function InsertStandardComment(){
// Url to start the agent
var url = window.document.getElementById("dbPath").value + "/InsertComment?openagent";
var urlReturn = window.document.getElementById("Path_Translated").value + "/?OpenForm";
if (window.document.applets[0]){
window.document.getElementById("tempString").value = window.document.applets[0].getSelectedDocumentsEx();
Check = confirm("You have selected " + window.document.getElementById("tempString").value.split(",").length + " document(s) for StandardComemnt, do you really want to continue?");
if (Check){
alert(window.document.getElementById("tempString").value);
window.document.forms[0].submit();
window.location=url;
//window.location=urlReturn;
}
}
}
Und hier der Agent:
Sub Initialize
Dim s As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim ermComment As String
Dim trmComment As String
Dim docArray As Variant
On Error Goto errHandle
Set db = s.CurrentDatabase
ermComment = "ermcomment"
trmComment = "trmcomment"
' Set Comment for selected Docs
docArray = Split(viewDoc.tempString(0), ",")
Forall unid In docArray
Set doc = db.GetDocumentByUNID(unid)
If(doc.ErmTrmFlag(0) = "TRM") Then
doc.trmComment(0) = trmComment
Else
doc.ermComment(0) = ermComment
End If
Call doc.Save( False, True )
End Forall
Exit Sub
errHandle:
Exit Sub
End Sub
Ich glaub das das mit dem Speichern des $$ViewTemplateDefault irgendwie nicht richtig hinhaut???
Danke vielmals
Alex
Edit: Ach ja - hatte ich vergessen - im OnSubmit dieser Maske hab ich noch @Command([FileSave]) drinnen