最新のドキュメント(2か月より新しいもの)のみを含むビューを作成したい。私はこの選択formularを使用しています:私はことを読んでいるので5259600秒で2ヶ月です注記式言語の日付差
SELECT @IsAvailable($Conflict) and docForm="ServiceOrders" and (@Today-PosDesValidFrom)<5259600
- オペレータは、時間枠を秒で返します。 私の見解では何の結果もありません。
最新のドキュメント(2か月より新しいもの)のみを含むビューを作成したい。私はこの選択formularを使用しています:私はことを読んでいるので5259600秒で2ヶ月です注記式言語の日付差
SELECT @IsAvailable($Conflict) and docForm="ServiceOrders" and (@Today-PosDesValidFrom)<5259600
- オペレータは、時間枠を秒で返します。 私の見解では何の結果もありません。
なしビュー選択式で@Todayまたは@Nowを使用します。ビューのインデックスは更新されることはありません。そのため、更新タスクは常にインデックスを更新するために実行されます。これはパフォーマンスのネガに影響します。
あなたがする必要があるのは、ビューに表示する文書にフラグを付ける毎日(おそらく夜間)のエージェントです。 エージェントをできるだけ早く作成するには、列の1つに日付を表示するビューを処理します。
絶対に最も速いのは、次のようになります。
1)(LookupServiceOrdersByValidDate)
と呼ばれる隠しビューを作成します。
2)最初の列にはフィールド名PosDesValidFrom
が含まれます(これは日付フィールドとみなされます。そうでなければ、日付に変換する必要があります)。降順でソートされます。カラムのinfoboxの4番目のタブに移動し、Date/Timeに設定していることを確認します。
3)テキストフィールドDisplayIn2MonthView
を表示する2番目の列を作成します。降順で並べ替えます。
4)ビューを保存します。
これで、エージェントを使用してループできるビューが作成されました。 2ヶ月以上前の日付に達するとすぐに、最新のものから順にソートされますので、エージェントを停止して実行することができます。
スクリプトは次のようなものになります。文書を表示するビューを変更し、最後に
Dim session as New NotesSession
Dim db as NotesDatabase
Dim view as NotesView
Dim col as NotesViewEntryCollection
Dim entry as NotesViewEntry
Dim doc as NotesDocument
Dim validDate as NotesDateTime
Dim cutoffDate As NotesDateTime
' Get current date and time and go back 2 months
Set cutoffDate = New NotesDateTime(Now())
Call cutoffDate.AdjustMonth(-2)
' Drill down to view
Set db = session.CurrentDatabase
Set view = db.GetView("(LookupServiceOrdersByValidDate)")
' Create a collection of all entries in the view and loop through them
Set col = view.AllEntries
Set entry = col.GetFirstEntry()
Do Until entry is Nothing
' Get value in first column in view and use it to create new DateTime object
validDate = New NotesDateTime(entry.ColumnValues(0))
' Check if we are within the 2 month cutoff date
If Cdat(validDate.dateOnly)>=Cdat(cutoffDate) Then
' Get document and set flag to display
Set doc = entry.Document
Call doc.ReplaceItemValue("DisplayIn2MonthView","Yes")
Call doc.Save(True,False)
Else
' We are beyond the cutoff date, but we need to clear old flags.
' Read the value in the second column and see if it is "Yes"
If entry.ColumnValues(1)="Yes" Then
Set doc = entry.Document
Call doc.ReplaceItemValue("DisplayIn2MonthView","")
Call doc.Save(True,False)
Else
' Since all "Yes" values should be at the top, if we
' get here there should be no more flagged documents.
Exit Do
End If
End If
Set entry = col.GetNextEntry(entry)
Loop
Print "All done."
を。おそらく、docForm
ではなく、Form
フィールドを使用してください。選択式を
SELECT [email protected]($Conflict) AND Form="ServiceOrders" AND DisplayIn2MonthView="Yes"
に設定するビューには、過去2ヶ月以内にValidDateを含むServiceOrderドキュメントのみが含まれるようになりました。 あなたが本当に唯一の複製をしたい場合は/ビューは、階層内のない表示返答文書に設定されていることを確認し、ビューで競合を保存する(ボックスをオフ):
非常に知的なアイデア、不幸なことですフォームに新しいフィールドを作成する権限がありません。 – Curunir
何らかの理由でcutoffDateの型が不一致になっています:CDat(validDate.dateOnly)> = CDat(cutoffDate) – Curunir
@exasswedeこの解決方法は私には当てはまりますが、問題は新しい順序がビュー上でエージェントが実行されます。 – Curunir