Running an agent from a QuerySave

I have an agent that I wrote a while ago that just returns an email address using @DbLookup. Its basically just a database with email addresses and a few views, nothing really complex. I wanted to know if I could return a value from that agent in a QuerySave I’m writing in LotusScript. The original agent is in Formula language. Can this be done?

I have tried rewriting the code in LotusScript , however, I can’t get it to work. I have posted the code below. It only returns a type mismatch error.

Dim session2 As New NotesSession

           Dim dbPrefManu As NotesDatabase    

           Dim workspace As New NotesUIWorkspace   

           Dim classview As NotesView

           Dim uidoc As NotesUIDocument

           Dim doc2 As notesdocument

           Dim key As String

           Dim email As String

           key = supplier_name

           

           Set uidoc = workspace.CurrentDocument

           Set dbPrefManu = session2.GetDatabase("srv-notes4/Adtran1", "practice\TestPreferredParts.nsf")  

           Set classview = dbPrefManu.GetView("Mfr Master")     

           Set doc2 = classview.GetDocumentByKey(key)

           email = doc2.GetFieldText("Email_Add")  

           Msgbox "Email:" & email

Subject: Running an agent from a QuerySave

the line should read

email = doc2.getItemValue( “email_Add”)( 0)

you were using the UiClass and not the back end class.

John

Subject: Running an agent from a QuerySave

Your key is not set.

key = supplier_name (but what is supplier_name)

Subject: RE: Running an agent from a QuerySave

The key is set to something else within the script named supplier_name. Its the result of an sql query.