I am having problems getting a WebQuerySave agent to run. The application was developed using R5 and the agent and form ran as they should. I made small modifications to a completely unrelated form and saved it using designer 6.5. After doing this, anytime I tried to save a document I received a page not found error (it did not go to where the $$Return specified) and the document did not save (no matter whether I tried to save, exit, or go to another form). After spending hours trying to find a solution I eventually changed “ToolsRunMacro” in the WebQuerySave to “RunAgent”. This allowed me to save the document and be redirected appropriately, but the agent still does not run. I eventually did a workaround and reverted the application back to R5 to fix this issue. How can I continue to develop applications in 6.5 and use WebQuerySaves at the same time? Thanks.
Subject: WebQuerySave Error
WQS works just fine in Domino 6.5, but your code may not. Care to share?
Subject: RE: WebQuerySave Error
Ditto. Exactly what are you looking at to when the code fails? If you aren’t sure, try putting in Print lines in various places. Then when you run the webquerysave agent you can see where it stops.
Print “Testing 1”
more code…
Print “Testing 2”
more code…
Print “Testing 3”
Etc, etc. Give it a try and give us an idea where in the code things are failing. Then provide the code. ![]()
Subject: RE: WebQuerySave Error
Here is all of the code in the agent. I left it all in here to give you all of the details. Thanks again for any help you can provide.
Option Public
Option Explicit
Sub Initialize
' this agent uses the 'Ready to archive' view to find the docs that meet the criteria.
Dim s As New NotesSession
Dim db As NotesDatabase
Set db = s.currentdatabase
' Set up agent logging
Dim verbose As Integer
verbose = 0
'verbose = 1
’ verbose = 2
Dim server As String
server = db.server
Dim agent As NotesAgent
Dim AgentLog As NotesLog
Call SetupAgentLog( db,s, agent, server,AgentLog, verbose )
If verbose >0 Then Call AgentLog.Logaction ("Starting Agent" )
Dim doc As notesdocument
Set doc = s.documentcontext
Dim counterview As notesview
Set counterview = db.getview("counter")
Dim numdoc As notesdocument
Dim tempnum As String
Dim temptype As String
Dim MyURL As String
If doc.lapnumyear(0)="" Then
If verbose >0 Then Call agentlog.logaction(" need to assign number")
' get the most recent number from the view
Set numdoc =counterview.getfirstdocument
temptype = doc.laptype(0)
If verbose >0 Then Call agentlog.logaction(" temptype is " + temptype)
If Not (numdoc Is Nothing) Then
Dim parsenum As String
parsenum = numdoc. lapnumyear(0)
' parse the existing doc to get the most recent number
Call ParseNumber (agentlog, verbose, parsenum, tempnum)
Else
' no laps yet in the view - this one is the first
tempnum="00001"
End If
'determine fiscal year
Dim FY As String
Dim tempFY As String
Call GetFY(Agentlog , verbose , FY ) ' FY is the 2 digit year
Dim newlapnum As String
newlapnum = tempnum+"-"+FY
If temptype = "SW" Then
' append sw to the number
newlapnum = newlapnum+temptype
Else
' do nothing
End If
doc.lapnumyear= newlapnum
Call doc.save (True, False)
If verbose >0 Then Call agentlog.logaction (" Saved the doc")
myURL = db.filepath+"/thanks--f?openform&"+newlapnum
Else
'doc already has a number
If verbose >0 Then Call agentlog.logaction(" doc already has a number")
myURL = db.filepath+"/thanksmod?openform&"+doc.lapnumyear(0)
End If
'tell the user thanks
Print "[" & myURL & "]"
If verbose>0 Then Call agentlog.logaction ( "Agent Finished Successfully")
Call AgentLog.Close
End Sub
Sub SetupAgentLog(db As notesdatabase, s As notessession, agent As notesagent, server As String,_
AgentLog As NotesLog, verbose As Integer )
’ Set up the agent log to record progress
Dim runname As String
Set agent = s.CurrentAgent
runname = agent.Name
Set AgentLog = New NotesLog ( db.filename+ ": "+ runname )
’ Set AgentLog = New NotesLog ( " agentName" )
Call AgentLog.OpenNotesLog( server, "agentlog.nsf" )
End Sub
Sub GetFY( Agentlog As noteslog, verbose As Integer, FY As String )
Dim currentdate As New NotesDateTime( "" )
Call currentdate.SetNow
If verbose =1 Then Call agentlog.logaction ( " get Fiscal year" )
Dim tempmonth As Integer
tempmonth = Month(currentdate.dateonly)
If verbose =2 Then Call agentlog.logaction ( " tempmonth is " + Cstr(tempmonth) )
If tempmonth <10 Then
'tempFY =Cint(Year(CurrentDate.dateonly))
FY = Right(Cstr(Year(CurrentDate.dateonly)),2)
Else
' add one to current year
fy = Right(Cstr(Year(CurrentDate.dateonly)+1 ),2)
'tempFY = Cint(Year(CurrentDate.dateonly))+1
End If
If verbose >0 Then Call agentlog.logaction( " FY is " + fy)
End Sub
Sub ParseNumber(agentlog As noteslog, verbose As Integer, parsenum As String, tempnum As String )
' we need to get the left portion of the existing number
Dim dash As String
dash = "-"
If verbose >1 Then Call agentlog.logaction( "parsenum is "+ parsenum)
Dim posofdash As Integer
posofdash = Instr(1,parsenum, dash)
If verbose >1 Then Call agentlog.logaction (" posofdash is " + Cstr(Posofdash) )
tempnum = Left(parsenum, (posofdash-1))
If verbose >0 Then Call agentlog.logaction (" tempnum is " + tempnum)
tempnum = (Cint(tempnum) + 1)
Call AddLeadingZeros(agentlog, verbose, tempnum)
End Sub
Sub AddLeadingZeros(agentlog As noteslog, verbose As Integer, tempnum As String)
' first get the length of the tempnum
Dim templen As Integer
templen = Len(tempnum)
If templen = 1 Then
tempnum = "000"+ tempnum
Elseif templen = 2 Then
tempnum = "00"+ tempnum
Elseif templen = 3 Then
tempnum = "0"+ tempnum
Else
'we dont have to do anything - the number is already 4 digits
End If
' return to the calling sub
If verbose >0 Then Call agentlog.logaction(" tempnum is now " + tempnum)
End Sub