hi all
Im trying to get two webfield values using javascript and lotus script.
the scenario is :
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 ave same two fields namely Answers and Docids in the webform and when submitting the webform with values entered in those HTML fields i can get the same values in teh 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.