Lotusscript agent not working

I am trying to write a LotusScript agent that processes against a view of parent documents and for each parent document uses the universalID to see if there are any response documents.

%REM

Agent Search_For_ActionItemIssues_Responses

Created Nov 16, 2010 by Gary Ashford/GV/FD/FluorCorp

Description: Comments for Agent

%END REM

Option Public

Option Declare

Sub Initialize()

Dim db1 As NotesDatabase

Dim doc1 As NotesDocument

Dim s1 As New NotesSession

Dim view1 As NotesView

Dim collection1 As NotesDocumentCollection

Dim strID As String*32

Dim searchFormula As string

Set db1 = s1.currentdatabase

Set view1 = db1.getview("MainTopicLookup")

Set doc1 = view1.getfirstdocument

While Not(doc1 Is Nothing)

	strID = doc1.UniversalID 

	MessageBox "UniversalID=" + strid

’ searchFormula = |Form = “ActionItemIssue” & $Ref = strID)|

’ searchFormula = |Form = “ActionItemIssue” & $Ref = @DocumentUniqueID)|

’ searchFormula = |Form = “ActionItemIssue” & @Text($Ref) = " | + strID + |" |

	searchFormula = |Form = "ActionItemIssue" & @Contains(@Text($Ref);" | + strID + |") |

	Set collection1 = db1.Search(searchFormula, Nothing,0)

	MessageBox "collection_resp count=" + CStr(collection1.count)

	Set doc1=view1.GetNextDocument(doc1)

Wend

End Sub

As you can see, I have tried several search formulas and never get a match, even though there are response (ActionItemIssue) documents in the database.

I have used debug and everything looks good, but I am not getting any matches.

Any help would be greatly appreciated.

Subject: Working good

Terry, Charlie

Thanks for the quick responses. I used responses and it worked fines. I had to add a few lines of code to process the collection, but everything is working good.

Subject: Why not just use the “Responses” property

Hi Gary,

You can create a document collection ALOT faster/easier than that.

Simply use script similar to the following:

Set collection1 = doc1.Responses

You can then evaluate the documents that are collected in that collection, and remove those that don’t fit the bill (for instance, if you only want documents that use a particular form).

Hope that helps!

T.

Subject: Try doc1.Responses

The Universal ID is not quite the same at the $REF in its raw form.

Perhaps doc1.Responses (which returns a Notesdocumentcollection) would suit your needs.