Das Notes Forum

Domino 9 und frühere Versionen => ND8: Entwicklung => Thema gestartet von: Vigeli am 30.07.08 - 16:58:23

Titel: bestimmte ansicht im hintergrund öffnen...............
Beitrag von: Vigeli am 30.07.08 - 16:58:23
hallo leute

brauche eure hilfeeeeee!!!!

möchte eine bestimmte ansicht via agent im hintergrund öffnen...............dann prüfen ob im feld FELD1 wert WG1 drin steht ....wen dies so ist sollte anschliessend andere feld mit FELD2 mit werten aus feld WERT1 gefühlt werden.....und nacher alles speichern

gibt es ein script (bespiel) hierfür?

besten dank
Titel: Re: bestimmte ansicht im hintergrund öffnen...............
Beitrag von: WernerMo am 30.07.08 - 17:06:01
Hallo,

muss es script sein, in Formel wäre das ein Fall für "@DBLookup".

Gruß Werner
Titel: Re: bestimmte ansicht im hintergrund öffnen...............
Beitrag von: Vigeli am 30.07.08 - 17:16:08
....ja am liebsten ein script.....sollte wen möglich als agent mehrmals täglich laufen
Titel: Re: bestimmte ansicht im hintergrund öffnen...............
Beitrag von: WernerMo am 30.07.08 - 17:20:32
Hallo,

nochmal ganz von vorne, Du willst einen periodischen Agenten machen, der alle Dokumente einer bestimmten Ansicht durchgeht und dann in jedem Dokument Felder ändert?

Evtl. in der DesignerHilfe NotesDocumentCollection
oder
http://atnotes.de/index.php?topic=41924.msg268775#msg268775

Gruß Werner
Titel: Re: bestimmte ansicht im hintergrund öffnen...............
Beitrag von: flaite am 30.07.08 - 17:20:59
Habs nicht getestet, könnte aber klappen
Code
Sub Initialize
	On Error Goto Fehler
	Dim s As New notessession
	Dim db As NotesDatabase
	Dim vw As NotesView
	Dim col As NotesDocumentCollection
	Dim doc As NotesDocument
	
	Dim searchVal As String
	Dim index As Variant
	
        dim counter as long

	searchVal = "WG1"
	counter = 0
Set db = s.currentDatabase
	Set vw = db.getView("HIER_DEN_VIEW_NAMEN_REINSCHRIBEN")
	Set col = vw.getAllDocumentsByKey("RandomKey den es bestimmt nicht gibt") ' diese Zeile nicht ändern :-)
	
	Set doc = vw.getFirstDocument()
	Do Until doc Is Nothing
		col.addDocument doc
		Set doc = vw.getNextDocument(doc)
	Loop
	
	Set doc = col.getFirstDocument
	Do Until doc Is Nothing
		index = Arraygetindex(doc.getItemValue("Feld1"), searchVal)
		If index <> Null Then 
			doc.replaceItemValue "Feld2", doc.getItemValue("Feld1")
			doc.save True, False
                        counter = counter + 1

		End If
		Set doc = col.getNextDocument(doc)
	Loop
	msgbox Cstr(counter) & " documents have been changed by this friendly agent."
Ende:
	Exit Sub
Fehler: 
	Msgbox "Fehler -> " & Error$ & "(" & Cstr(Err) & ") in Zeile: " & Cstr(Erl)
	Resume ende
End Sub