Is this true: Background agent can NOT access database from a different server? Help!

Hi,

I have an agent that scans mail to retrieve information from certain type of mail then update a form on the database from a different server. It works fine if it executes from an action button but for “Before/After mail arrives” or On Schedule - Daily, the code is dead when it get a handle of a view of a database on another server. I know that since I add some debug code by sending myself a mail . Here is my code :


Sub Initialize

Set session = New NotesSession

Set db = session.CurrentDatabase

Set doc =session.DocumentContext

Subject = doc.Subject(0)   

formName = doc.Form(0)

'Starting code to search for  alerts

Fromtemp = "Store"

FromSender = doc.From(0)



SearchforString1X223 = "DeCa Alert: StoreGazer"

SearchforString2X223 = "posted a X223 at"

'****************************************************

'****Make sure the sender start with "Store"

positionOfFrom = Instr(FromSender$, Fromtemp$)

positionOfString1X223 = Instr(Subject$ , SearchforString1X223$ )

positionOfString2X223 = Instr(Subject$ , SearchforString2X223$ )

'***End Code for  alerts****************

If (positionOfString1X223 <>0) And (positionOfString2X223 <> 0) And (positionOfFrom<>0) And formName = "Memo"   Then

	Call ProcessX223Alert

End If

End Sub


Sub ProcessX223Alert

'Get X223 Datetime and StoreID 

On Error Goto Somethingwrong

Call GetX223Info

Set dbDeCA = New NotesDatabase( "US-FAIRDEV001/Dev/US", "16TA\\DeCA_TLog.nsf" )

keys(1) = X223DateOnly                      'Search for date first  - Data get from Sub GetX223Info

keys(2) = StoreID                                     'then search for StoreID - Data get from Sub GetX223Info



Set ByKeyView = dbDeCA.GetView( "GetDocByKey" ) ''<------------------- Code dead after this line.

'******************* test to see where the problem is *****************

'Set memoform = New NotesDocument(db)

'memoform.form = "Memo"

'memoform.SendTo = "Hung Tran/Houston"

'memoform.subject = "Before New Mail:Sub ProcessX223Alert before GetView"

'Call memoform.Send(False,False)

'******************* End test *******************************************

Set TLogDoc = ByKeyView.GetDocumentByKey(keys)

If Not (TLogDoc Is Nothing) Then

       TLogDoc.X223Date = X223Date

        Call TLogDoc.Save(True,False)

End If

Exit Sub

Somethingwrong:

Msgbox "Something wrong on ProcessX223Alert"

End Sub


If I place test code lines that send mail to myself before the : Set ByKeyView = dbDeCA.GetView( “GetDocByKey” ) then I receive mails but nothing is executed after that line. If I place those test codes after the GetView line then no mail get sent! So obviously, Lotus Notes scheduled agent does not like a handle to a view from a different database + different server.

What do I need to do? Please help. Many thanks in advance.

Subject: Is this true: Background agent can NOT access database from a different server? Help!

do you get no error? It should work. Try adding some code to make sure that dbDeCA is open before you attempt to get the view.

Subject: RE: Is this true: Background agent can NOT access database from a different server? Help!

Hi Paul,

I don’t get ANY error!?! I wish I had so at least I had an idea what went wrong. Thank you. I will add code to open that database as you suggested.

Again, thanks for your kind help.

Subject: Is this true: Background agent can NOT access database from a different server? Help!

The signature of the agent on Server A has the rights to run on the server B?

If you were using something like Evaluate or Signing then it would use the server A signature for that, so you would require the rights of that server to run on the other server.

Subject: RE: Is this true: Background agent can NOT access database from a different server? Help!

Hi Simon,

Yes, I do use Evaluate in my agent code. Please elaborate on how I would be able to verify that I, who is the agent signee on server A, has the right on server B or is it server A signature(?) has the right on server B?

But I am curious on why it works if I set the same code to run as action button, except that I use DocumentContext for “Before new mail arrives” while using UnprocessedDocuments for Action button. Help, please.

Many thanks Simon.

Subject: RE: Is this true: Background agent can NOT access database from a different server? Help!

Hi Simon,

Yes, I do use Evaluate in my agent code. Please elaborate on how I would be able to verify that I, who is the agent signee on server A, have the right on server B or is it server A signature(?) has the right on server B?

But I am curious on why it works if I set the same code to run as action button, except that I use DocumentContext for “Before new mail arrives” while using db.UnprocessedDocuments (NotesDocumentCollection) for Action button. Help, please.

Many thanks Simon.