Domino 9 und frühere Versionen > ND7: Entwicklung
Inhalt eines Datumfelds loeschen per LS
lnfan:
Hallo,
habe ein Datumsfeld vom Type mm.yyyy
Möchte per LS Agenten den INHALT des Feldes löschen. Hatte laienhaft mit einem simplen Modify probiert und als Ziel einen Leerstring (keine Eingabe) verwendet, aber bei einem Datumsfeld kam da nichts Verfünftiges bei raus.
Wie lautet der Befehl zum Löschen des Inhaltes aus einem Datumsfeld?
Gruss, Manfred
PS: Wenn ich nach dem Datumsfeld kategorisiere (nach meinem Modify-Versuch) dann wird aus dem Kategorienamen "5.****" anstatt "not categorized".
koehlerbv:
Ein wenig Code wäre jetzt nicht schlecht. Dann könnte man auch sehen, ob Deine Bemühungen im Front- oder Backend erfolgen.
Backend:
NotesDocument.DeinDatumsFeld = ""
oder
Set NotesItem = NotesDocument.GetItem ("DeinDatumsFeld")
Call NotesItem.Remove
Frontend: Kommt drauf an... Mehr Input, mehr Output.
Bernhard
lnfan:
Hallo nochmal,
ich hätte Input geliefert, wenn ich welchen hätte. Habe ich etwa zu einfach gedacht? Ich brauche doch sicherlich nicht zeilenweise von Code. Einfach nur Löschen.
Dann werde ich mit deinen Tipps mal recherchieren und probieren. Danke.
Gruss, Manfred
Ergänzung:
Der Rumpf kann doch weiterverwendet werden. Nur anstatt der Zuweisung eines neuen Datums soll eine Löschung des Feldinhaltes erfolgen.
'if no documents have been selected then exit routine
If collection.Count = 0 Then Exit Sub
msg = collection.Count & " documents have been selected for mass update. Please enter a new date."
response = ws.Prompt (PROMPT_OKCANCELEDIT, _
"Change Date...", msg, "06.2006")
If response = "" Then Exit Sub
strTempDate = "01." & response
Set doc = collection.GetFirstDocument
While Not (doc Is Nothing)
'Here the field will be changed per doc with the value selected in the prompt
doc.ASD_Depl_Date = Cdat(strTempDate)
doc.Header_UpdName = nam.Abbreviated
doc.Header_UpdCreated = Now()
'Save the current document
Call doc.Save(True, False)
Set doc = collection.GetNextDocument(doc)
Gruss, Manfred
MadMetzger:
Und wie das geht hat Bernhard doch geschrieben. Bei der Variante doc.Feld = "" kannst du auch ein collection.stampAll("Feld","") verwenden, das ist dann wesentlich weniger Code.
lnfan:
Hallo nochmal,
habe mal den Vorschlag von Bernhard eingebaut (beide Statements IN die Schleife?). Syntaktisch ist der Code korrekt. Beim Aufruf des Agenten aus der View kommt dann nach meiner Hinweisbox die Notes-Meldung "Variant does not contain an object".
Fehlt da noch eine Initialisierung? Danke für einen Hinweis.
Gruss, Manfred
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Dim ws As New NotesUIWorkspace
Dim nam As NotesName
Dim msg As String
Dim response As Variant
Set db = session.CurrentDatabase
Set collection = db.UnprocessedDocuments
Set nam = session.CreateName(session.UserName)
'if no documents have been selected then exit routine
If collection.Count = 0 Then Exit Sub
msg = collection.Count & " documents have been selected for deletion of the deployment dates . Do you want to proceed?"
response = ws.Prompt (PROMPT_YESNO, "Clear Deployment Date...", msg)
If response = 0 Then Exit Sub
Set doc = collection.GetFirstDocument
While Not (doc Is Nothing)
'Here the fields will be changed per doc
Set NotesItem = NotesDocument.GetItem (ASD_Depl_Date)
Call NotesItem.Remove
doc.Header_UpdName = nam.Abbreviated
doc.Header_UpdCreated = Now()
'Save the current document
Call doc.Save(True, False)
Set doc = collection.GetNextDocument(doc)
Wend
End Sub
Navigation
[0] Themen-Index
[#] Nächste Seite
Zur normalen Ansicht wechseln