Hello Everybody
iam getting a Webquerysave agent Error which is “Object variable not set” Error whenever i try to run the agent from a browser on form submit.
following is my scenario :
Im trying to get two webfield values using javascript and lotus script.
i have two fields namely
1.Answers
2.Docids
the two fields above said are dynamically generated through HTML tags by another agent.
now i have same two fields namely Answers and Docids in the webform(Notes field’s) and when submitting the webform with values entered in those HTML fields i can get the same values in the Notes field’s
this can be accomplished by a WQS agent using Session.DocumentContext property
now what iam exactly doing is getting the document ids from the Docids HTML field and using the WQS agent getting a handle to the document which is residing in another Database say DB1.
and iam getting a column value from the document and matching the same with the Answers HTML field.
the point is to perform a equality test between the choice got from the Answers HTML field and the original Answer from the document in DB1.
whenever i try to do this iam getting an “Object variable not set” error at the last document.
Anybody can help me please. its very urgent.
iam attaching the WQS Agent code hereby.
Sub Initialize
Dim db As NotesDatabase
Dim db1 As NotesDatabase
Dim doc As NotesDocument
Dim doc1 As NotesDocument
Dim doc2 As NotesDocument
Dim vw As NotesView
Dim webans As Variant,webdocid As Variant,x As Variant,y As Variant,correctans As Variant,userans As Variant,correct As Variant,wrong As Variant,totalscore As Variant
Dim ansstring As Variant,docidstring As Variant,docidcount As Variant,anscount As Variant,temp1 As Variant ,var3 As Variant,var4 As Variant
Dim temp As Variant,var1 As Variant,var2 As Variant,delim As String,last As String,final As String,sepr As String,id As Variant
Dim item As NotesRichTextItem
Dim ss As New NotesSession
Set db=ss.CurrentDatabase
Set doc=ss.DocumentContext
Set db1=ss.GetDatabase(“Training”,“OnlineRecruitment\Testingphase2.nsf”,“”)
Msgbox “DB 1 ok”
Set vw=db1.GetView(“vwunids”)
Msgbox “view ok”
Set doc1=db.CreateDocument
Set doc2=db.CreateDocument
webans=doc.GetItemValue(“Answers”)(0)
webdocid=doc.GetItemValue(“Docids”)(0)
Msgbox " web fields ok"
Msgbox webans
Msgbox webdocid
’ performing splitting operation for both userchosen answer and document id’s
Msgbox" removing the ; from the string containment for document id’s "
temp=webdocid
var1=Len(temp)
var2=(var1-1)
last=Left(temp,var2)
Msgbox " performing split operation for document id’s"
delim=“;”
docidstring=Split(last,delim)
docidcount=Ubound(docidstring)
Msgbox " removing the ; from the string containment for userchosen answers"
temp1=webans
var3=Len(temp1)
var4=(var3-1)
final=Left(temp1,var4)
Msgbox " performing split operation for userchosen answer’s"
sepr=“;”
ansstring=Split(final,sepr)
anscount=Ubound(ansstring)
Msgbox " initialise correct and wrong score "
correct=0
wrong=0
y=0
Msgbox docidcount
Msgbox anscount
Msgbox " looping through the document id’s to get the correct answer from DB1 for the question given."
Forall docid In docidstring
id=docid
Msgbox id
Set doc2=vw.GetDocumentByKey(id,True)
correctans=doc2.GetItemValue(“origans”)(0)
Msgbox "correct answer is : "&correctans
userans=ansstring(y)
Msgbox "user chosen answer is : "&userans
Msgbox " answer comparison and score computation"
If(correctans=userans) Then
correct=correct+1
Msgbox correct
Else
wrong=wrong+0.25
Msgbox wrong
End If
y=y+1
End Forall
Msgbox “exiting for loop”
totalscore=(correct-wrong)
Msgbox "correct score is : " & correct
Msgbox "Wrong score is : " & wrong
Msgbox "Your total score is : " & totalscore
Msgbox “saving document”
doc1.form=“frmresult”
doc1.fldcorrect=correct
doc1.fldwrong=wrong
doc1.fldtotalscore=totalscore
Call doc1.Save(True,False)
Print “WQS done !”
End Sub
Any body please help me on this issue.
i checked if any problem persists with the loop boundaries and the whole code is working cool in notes client.
but the only problem is when it comes to web.
may be it is concerned with document context or doc.getitemvalue ???
also i had located the error line which is from the agent log and is as below.
12/04/2006 08:13:52 PM Agent message: DB 1 ok
12/04/2006 08:13:53 PM Agent message: view ok
12/04/2006 08:13:53 PM Agent message: web fields ok
12/04/2006 08:13:53 PM Agent message: no;yes;Lotus Inc;
12/04/2006 08:13:53 PM Agent message: 25B7E346B286F4466525721C0024DEBA;36B32E9D800A57D76525723A0019FC1D;FAA95B2A8DBEDE
4B6525723A001A0887;
12/04/2006 08:13:53 PM Agent message: removing the ; from the string containment for document id’s
12/04/2006 08:13:53 PM Agent message: performing split operation for document id’s
12/04/2006 08:13:53 PM Agent message: removing the ; from the string containment for userchosen answers
12/04/2006 08:13:53 PM Agent message: performing split operation for userchosen answer’s
12/04/2006 08:13:53 PM Agent message: initialise correct and wrong score
12/04/2006 08:13:53 PM Agent message: 2
12/04/2006 08:13:53 PM Agent message: 2
12/04/2006 08:13:53 PM Agent message: looping through the document id’s to get the correct answer from DB1 for the question given.
12/04/2006 08:13:53 PM Agent message: 25B7E346B286F4466525721C0024DEBA
12/04/2006 08:13:53 PM Agent message: correct answer is : no
12/04/2006 08:13:53 PM Agent message: user chosen answer is : no
12/04/2006 08:13:53 PM Agent message: answer comparison and score computation
12/04/2006 08:13:53 PM Agent message: 1
12/04/2006 08:13:53 PM Agent message: 36B32E9D800A57D76525723A0019FC1D
12/04/2006 08:13:53 PM Agent message: correct answer is : yes
12/04/2006 08:13:53 PM Agent message: user chosen answer is : yes
12/04/2006 08:13:53 PM Agent message: answer comparison and score computation
12/04/2006 08:13:53 PM Agent message: 2
12/04/2006 08:13:53 PM Agent message: FAA95B2A8DBEDE
4B6525723A001A0887
12/04/2006 08:13:53 PM Agent message: object variable not set
im wondering that i have a document by the unid starting with FAA95… but why iam getting an Object variable not set error.
after performing error handling im getting out of the loop at the last document.
iam going crazy. please drop your suggestion on this i will be very thankfull.
please help me on this…