Agent not running / getting called

I have a lotus script Exiting function on a field that calls an agent on the server. I’m not sure what I’ve done to stop this from working. It has been working for quite sometime.

When I walk the code through the debugger, it looks as though it calls the agent, but the action skips over the agent code and completes the rest of the commands. Unfortunately, it returns no data because the agent does not run.

I inserted a msgbox before and after the

Call agent.RunOnServer(parmid) line, and both boxes displayed the message, but alas, the agent did not run.

Here is my code. Your help is Greatly appreciated.

Jeff

Uselsx “*LSXODBC”

Dim doc As notesdocument

Dim tempDoc As notesdocument

Dim uidoc As NotesUIDocument

Dim view As NotesView

Dim fUpcNum As String

Dim fCost As String

Dim fRetail As String

Dim fSell As String

Dim fSize As String

Dim fSizeDesc As String

Dim fPack As String

Dim fDescription As String

Dim fDepartment As String

Dim fDepartment_1 As String

Dim fProductType As String

Dim fProductType_1 As String

Dim count As Integer

Dim lineNumItem As String

Dim lineItem As String

Dim fromUnits As String

Dim incUnits As String

Dim incCases As String

Dim fromCases As String

Dim fTotalRetail As String

Dim fTotalCost As String

Dim msg As String

Dim upcVar As String

Dim boxType2 As Long, answer2 As Integer

Dim boxType3 As Long, answer3 As Integer

Dim boxType1 As Long, answer1 As Integer

Dim iFromRetail As String

Dim iFromTotalRetail As String

Dim iFromSell As String

Dim iFromStore As String

Dim iToStore As String

Dim pbsFlag As String

Dim itemVendUPCVar As String

Sub Exiting(Source As Field)

Dim s As New NotesSession

Dim w As New NotesUIWorkspace

Set db=s.CurrentDataBase

Dim msg As String

Dim agent As NotesAgent

Dim item As NotesItem



Set agent = db.GetAgent("(findItem)")

Set uidoc = w.CurrentDocument

Dim parmid As String



Set doc = uidoc.document

If doc.vendorItemNum(0) = "" Then 

	Exit Sub 	

Else

	itemVendUPCVar = doc.vendorItemNum(0)

	iFromStore = doc.sendStorenum(0)

	iToStore = doc.recStorenum(0)

	Set tempDoc = db.CreateDocument

	Set item = tempDoc.AppendItemValue("upcNum",upcVar)

	Set item = tempDoc.AppendItemValue("costAmount",0) 

	Set item = tempDoc.AppendItemValue("retailAmount",0) 

	Set item = tempDoc.AppendItemValue("retailMultiplier",1)

	Set item = tempDoc.AppendItemValue("sizeNum",0) 

	Set item = tempDoc.AppendItemValue("sizeDescr","") 

	Set item = tempDoc.AppendItemValue("packNum",0)

	Set item = tempDoc.AppendItemValue("upcDescr","") 

	Set item = tempDoc.AppendItemValue("deptDescr","")

	Set item = tempDoc.AppendItemValue("iFRetail",0)

	Set item = tempDoc.AppendItemValue("iFSell",1)

	Set item = tempDoc.appendItemValue("fromStore",iFromStore)

	Set item = tempDoc.appendItemValue("toStore",iToStore)

	Set item = tempDoc.AppendItemValue("pbsFlag","N")

	Set item = tempDoc.AppendItemValue("vendItemUPCNum",itemVendUPCVar)

	

	Call tempDoc.save(True,True)

	parmid = tempDoc.Noteid

	

	Call agent.RunOnServer(parmid)

	

	Delete tempDoc

	Set tempDoc = db.GetDocumentById(parmid)

	

	pbsFlag =tempDoc.pbsFlag(0)

	If pbsFlag = "Y" Then

		

		Dim boxType1 As Long, answer1 As Integer

		boxType1& = 0 + 16

		answer1% = Messagebox("This is a Scan Based Trading Item and cannot be transferred.", boxType1&, _ 

		"Cannot transfer a SBT Item")

		Call uidoc.GotoField( "upc_1" )

		doc.upc_1 = ""

		

		Exit Sub

		

	Else

		fUpcNum = tempDoc.upcNum(0)

		If fUpcNum = "does not exist" Then

			

			Dim boxType2 As Long, answer2 As Integer

			boxType2& = 0 + 16

			answer2% = Messagebox("No item is found for upc  "+upc+".  Please check the number and try again.", boxType2&, _ 

			"UPC Not Found")

			Call uidoc.GotoField( "upc_1" )

			doc.upc_1 = ""

			

			doc.continueFlag = "False"

			Exit Sub

		Else

			

			fCost = Cdbl(tempDoc.costAmount (0))

			fRetail = Cdbl(tempDoc.retailAmount(0))

			fSell = Clng(tempDoc.retailMultiplier(0))

			fSize = Clng(tempDoc.sizeNum (0))

			fSizeDesc = tempDoc.sizeDescr (0)

			fPack = Clng(tempDoc.packNum(0))

			If fPack = 0 Then fPack = 1

			fDescription = tempDoc.upcDescr (0)

			fDepartment = tempDoc.deptDescr(0)

			iFromRetail = Cdbl(tempDoc.iFRetail(0))

			iFromSell = Clng(tempDoc.iFSell(0))

			fSizeDesc = fSize+" "+fSizeDesc

			If fDepartment = "GENERAL MERCHANDISE" Then 

				fDepartment = "GM"

			End If

			doc.upc_1 = fUpcNum

			doc.description_1 = fDescription

			doc.pack_1 = fPack

			doc.sizeDesc_1 = fSizeDesc

			doc.fromSell_1 = fSell

			doc.fromRetail_1 = Cdbl(fRetail)

			doc.fromCost_1 = fCost

			doc.fromCost_1_1 = fCost

			doc.sendDept = fDepartment

			doc.recDept = fDepartment

			doc.department_1 = fDepartment

			doc.department_1_1 = fDepartment

			doc.fromSell_1_inc = iFSell

			If iFRetail = 0 Then 

				doc.fromRetail_1_inc = Cdbl(fRetail)

			Else 

				doc.fromRetail_1_inc = Cdbl(iFRetail)

			End If

		End If

	End If

	Call setValues 

End If

End Sub

Subject: Agent not running / getting called

When you step through the code in the debugger you shouldn’t expect it to ‘step into’ the (findItem) agent.

How have you determined that the agent isn’t being run on the server?

Try putting a simple print( “hello from findItem” ) statement at the very start of the (findItem) agent and then check the servers log after running your code. You should see the ‘hello from…’ message in the Log.

Frunobulax

Subject: RE: Agent not running / getting called

Thank you Frunobulax. The agent is getting called. I discovered that it was not connecting to the database because the datasources had been renamed using a different password. Thank you for your valuable reminder of using the notes log.Jeff

Subject: Agent not running / getting called

Hi,

you can not run an agent on the server if you use frontend - classes !

type the code into a button or a event of the field (example: onchange event)

Bernhard