0

日付の文字列のインスタンスごとにドキュメントを作成しようとしています。

ただし、これは期待どおりに機能しません。フィールドは更新されず、デバッガーは何も表示しません。

誰かが私のコードで正しい方向に向けることができますか?

Public Sub co_multiDates()

'Basic Error Handler function
'On Error GoTo errorHandler
'errorHandler:  MsgBox("ERROR " & CStr(Err) & ": " & Error$ & " on line " & CStr(Erl))

'Everything below this is designed to populate a field that then populates a column with multiple date values
'This is designed so that when creating a location record for multiple days, there will be multiple entries in the employee's view
Dim w As New NotesUIWorkspace       
Dim multiStartDate As NotesDateTime
Dim multiEndDate As NotesDateTime
Dim tempDate As NotesDateTime
Dim dateArray() As NotesDateTime
Dim dateCounter As Integer
Dim AdjustDay As Integer
Dim Source As NotesUIDocument
Set Source = w.CurrentDocument
Dim thisDoc As NotesDocument
Set thisDoc = Source.Document

' populate multiStartDate and multiEndDate with the values from the StartDate and EndDate fields
Set multiStartDate = New NotesDateTime(thisDoc.GetItemValue("StartDate")(0))
Set multiEndDate = New NotesDateTime(thisDoc.GetItemValue("EndDate")(0))

'assign null value to dateCounter   - calculates the difference between StartDate and EndDate
Let dateCounter = 0

While multiStartDate.TimeDifference(multiEndDate) <= 0

    'add to MultiDates
    ReDim Preserve dateArray(0 To dateCounter)
    Set tempDate = New NotesDateTime(multiStartDate.DateOnly)
    Set dateArray(dateCounter) = tempDate

    'add 1 to the date to loop
    Call multiStartDate.AdjustDay(1)
    dateCounter = dateCounter + 1
Wend

'Replaces the value of the MultiDatesArray field in newDoc (current document)  with the value of dateArray
Call thisDoc.ReplaceItemValue("MultiDates", dateArray)

'Updates audit trail field with any changes
Call SetAuditTrail(w.CurrentDocument.document, "auditTrailField", 1,  "PersonName", "Person Name")

End Sub

おそらく非常に明白な何かが欠けているように感じます。

ありがとう。

4

2 に答える 2

1

UI クラスを使用してドキュメントを更新しているという事実に基づいて、編集モードで開いているドキュメントから Notes クライアントでこのコードを実行していると想定しているため、上記を追加してそのコンテキストでテストしましたStartDate、EndDate、および Multidates フィールドを持つフォームのサブコードを作成し、そのフォームのボタンの Click イベントから呼び出します。StartDate と EndDate の間のすべての日付をフィールド Multidates に追加しましたが、これはまさにその意図した目的のようです。

範囲内の日付ごとにドキュメントを作成する場合は、While ループ内に次のようなコードを追加する必要があります。

' In your declarations...
Dim session as NotesSession
Dim thisDatabase as NotesDatabase
Set thisDatabase=session.CurrentDatabase

' In your loop...
Set newDoc=thisDatabase.CreateDocument
newDoc.Form="ChildForm" ' or whatever 
newDoc.myDate=dateArray(dateCounter)
' Do other stuff to the document, then...
Call newDoc.Save(False, True)

上記の仮定のいずれかが外れている場合は、質問を編集してコンテキストに関する詳細を追加すると、より良い回答が得られます。

于 2012-01-24T17:11:59.317 に答える
0

この関数が何をすべきかわかりません:Call SetAuditTrail(w.CurrentDocument.document, "auditTrailField", 1, "PersonName", "Person Name")

しかし、コードの残りの部分では、現在のドキュメントの保存および/または新しいドキュメントの作成は見られません。thisDoc.save(false,true)役立つかもしれません。

デバッガーがこのコードを実行しない理由がわかりません。

于 2012-01-24T14:28:45.960 に答える