2012-02-22 17 views
0

を動作しませんオブジェクト変数が設定されていないことを示します。私が紛失しているものを見つけるのを助けることができますか?LotusScriptのエージェントが、私はこのエージェントとの問題を抱えてい

ありがとうございます。

%REM 
Sub as_archiveOldDocuments 
Description: 
This agent archives documents that are more than one week old. 
This is so that the dataset used is kept current - view selections only select documents 
whose archived field value is equal to zero. For that reason, this agent detects whether 
or not a document in the set is more than a week old. If it is, the Archived field is 
marked as '1'. 

Function calls: N/A 
Sub calls: N/A 
Called in event: N/A 
Called by: ag_archiveOldDocuments 

%END REM 
Public Sub as_archiveOldDocuments 

Dim s As NotesSession 
Dim locDb As New NotesDatabase(****) 
Dim locView As NotesView 
Set locView = locDb.GetView("byNameDateLocCode") 
Dim dc As NotesDocumentCollection 
'Set dc = locDb.CreateDocumentCollection() 
Dim key (0 To 1) As Variant 
Dim archiveDate As NotesDateTime 
Set archiveDate = New NotesDateTime(Today) 
Call archiveDate.AdjustDay(-7) 
Dim thisDoc As NotesDocument 
Dim unarchived As Integer 
Let unarchived = "0" 

'populate key to build document collection, then build it 
key(0) = archiveDate.DateOnly 
key(1) = unarchived 
Set dc = locView.GetAllDocumentsByKey(key, True) 

'find first document in the collection 
Set thisDoc = dc.GetFirstDocument() 

'while the doc collection exists 
While Not dc Is Nothing 

    'if the date value in the document is less than the archiveDate value specified (today -7) 
    If thisDoc.Date <= archiveDate.DateOnly Then 

     'replace the archived value (which will be '0') with '1' 
     Call thisDoc.ReplaceItemValue("Archived", "1") 
     Call thisDoc.ComputeWithForm(False,True) 
     Call thisDoc.Save(True, False, False) 

    End If 

    Set thisDoc = dc.GetNextDocument(thisDoc) 

Wend 

End Subの

答えて

3

ほとんどの場合、この行は失敗している:あなたは、デバッガでlocViewのために参照してくださいかどう

Set locView = locDb.GetView("byNameDateLocCode") 

を?有効なビューでない場合は、ビュー名が上記と一致することを確認し、必要な権限を持っていることを確認するためにビューのデータベースACLと制限を確認します。エージェントがWebエージェントとして実行されている場合は、エージェントの実行時IDの設定に応じて、署名者および/またはサーバーに必要な権限があることを確認してください。データベースlocDbがエージェントが実行されているサーバーとは別のサーバーにある場合は、エージェントサーバーにターゲットサーバーによって「信頼されたサーバー」権限が与えられていることを確認してください。

+0

多くのおかげで、これは非常に便利でした。 – Thomas

関連する問題