Hi there,
I’m having a classic front end / back end problem…
I have a form with a text box (CustSearchString), a result field (Result) and a “Search” Button. The button’s code looks like this:
Sub Click(Source As Button)
Dim workspace As New notesuiworkspace
Dim s As New NotesSession
Dim db As NotesDatabase
Dim doc As notesdocument
Dim uidoc As notesuidocument
Set uidoc = workspace.CurrentDocument
Set doc = uidoc.Document
Dim agent As NotesAgent
Set db = s.CurrentDatabase
Set agent = db.GetAgent(“LookupCustomer”)
If agent.RunOnServer(doc.NoteID) = 0 Then
Call uidoc.refresh
End If
End Sub
The agent “LookupCustomer” looks like this:
Sub Initialize
Dim agent As notesagent
Dim con As New ODBCConnection
Dim qry As New ODBCQuery
Dim result As New ODBCResultSet
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Set qry.Connection = con
Set result.Query = qry
Set agent = session.currentagent
Set db = session.CurrentDatabase
Set doc = db.GetDocumentByID(agent.ParameterDocID)
Set nResult = doc.GetFirstItem(“Result”)
con.ConnectTo(“as400”)
qry.SQL = "SELECT cmcsno, cmcsnm FROM aplus2fcm.cusms WHERE cmcsno = " + doc.CustSearchString(0)
result.Execute
result.NextRow
sfield = result.GetValue(1)
sCustomerNumber = Trim(sfield)
sfield = result.GetValue(2)
sCustomerName = Trim(sfield)
sResult = sCustomerNumber + " - " + sCustomerName
doc.Result = sResult
Call doc.Save(True,True)
con.Disconnect
End Sub
Everything is working fine except the uidoc doesn’t show the the new value for the “Result” field. But if I close the uidoc and reopen it, it shows up.
I’ve tried using uidoc.reload, and also tried refreshing/reloading the uidoc outside of the button script, but only closing and reopening seems to do the trick.
Any help would be appreciated,
Regards,
Scott McCoskery