I had this problem, when I click a button to submit the document. “Error : Please contact your administrator Error 91: Object variable not set” coming out in the browser. This is coding by javascript. Anyone know why this happend? Appreciated in advance for your help. Thanks you.
Subject: Object variable not set
There might be a LS Agent triggered by this button.
More details, better answer.
Subject: RE: Object variable not set
Exactly, you need to explain in detail if you expect someone to answer your queries. “Object variable not set” as the sentence clearly indicates, comes when you try to use a object reference when it has not been set.
For eg:
set doc = view.GetFirstDocument
Print doc.UniversalID
assuimg that there is no document in the view,
this will raise an “object variable not set” error when you try to print the document unique id
cheers !!
Ashish
Subject: RE: Object variable not set
The code is something like below:
form’s onLoad:
…
document.forms[0].submit();
form’s webQuerySave:
@Command([ViewRefreshFields]);
@Command([ToolsRunMacro];“Compute”)
Is the problem related to Compute Agent?
Subject: RE: Object variable not set
Yes … it is the agent printing the message using a custom error handler i.e. look for “On Error Goto” statement in your agent. Also the line number mentioned in the error is the actual line in the agent throwing the error … so just try to figure out the reason or post your agent code here.
cheers !!
Ashish
Subject: RE: Object variable not set
Compute Agent’s Initialize:Sub Initialize
On Error Goto ErrorHandler
Dim ss As New notessession
Dim doc As notesdocument
Dim doc1 As notesdocument
Dim Profdoc As notesdocument
Dim fDate As notesdatetime
Dim tDate As notesdatetime
Dim db As notesdatabase
Dim ProfDB As notesdatabase
Dim ProfView As notesview
Dim col As notesdocumentcollection
Set db=ss.currentdatabase
searchFormula$ = "Form = ""ServerName"""
Set col = db.Search(searchFormula$,Nothing,0)
Set doc1=col.getfirstdocument
profPath=doc1.Emp_ProfileDBPath(0)
Set ProfDB=ss.getdatabase(db.server,profPath)
Set doc=ss.documentcontext
Set ProfView=ProfDB.getview("EmpProfile")
'tmp_saveFlag=doc.Save_Flag(0)
'tmp_submitFlag=doc.Submit_Flag(0)
'tmp_computeFlag=doc.Compute_Flag(0)
tmp_fdate=doc.Comp_Fdate(0)
tmp_tdate=doc.Comp_Tdate(0)
'tmp_totLev=doc.Tot_Leave(0)
eName=doc.Comp_EName(0)
LType=doc.Comp_LType(0)
Set ProfDoc=ProfView.getdocumentbykey(eName)
If ProfDoc Is Nothing Then
Print "<h2><font color='#FF0000'>Can not find your profile, Please contact administrator</font></h2>"
Exit Sub
End If
If LType="Annual" Then
quota=ProfDoc.B_Annual(0)
Elseif LType="Examination" Then
quota=ProfDoc.B_Exam(0)
Elseif LType="Maternity" Then
quota=ProfDoc.B_Maternity(0)
Elseif LType="Medical" Then
quota=ProfDoc.B_Medical(0)
Elseif LType="National Service" Then
quota=ProfDoc.B_Nst(0)
Elseif LType="Compassionate" Then
quota=ProfDoc.B_Comp(0)
End If
Set fDate=New NotesDateTime(tmp_fdate)
Set tDate=New NotesDateTime(tmp_tdate)
'Set item1=doc.getfirstitem("From_dt")
'Set item2=doc.getfirstitem("To_dt")
Ndays=tDate.timedifference(fDate)/86400+1
'doc.No_Days=tDate.timedifference(fDate)/86400+1
For j=1 To Ndays
tmp_wk=Weekday(fdate.lslocaltime)
If tmp_wk=1 Or tmp_wk=7 Then
i=i+1
End If
Call fdate.adjustday(1)
Next
Ndays=Ndays-i
If doc.Leave_Type(0)="Sick Leave" Then
Set fDate=New NotesDateTime(tmp_fdate)
Set tDate=New NotesDateTime(tmp_tdate)
Ndays=tDate.timedifference(fDate)/86400+1
End If
If Cdbl(Ndays)=0 Then
doc.Submit_Flag="False"
doc.Save_Flag="False"
doc.Emp_CurrStat=doc.Prev_Status(0)
'Print "<h2><font color='#FF0000'>Selected day is not a working day</font></h2>"
'Print"<br><h4> <a href=""JavaScript:history.go(-1)"">Back</a>"
'doc.SaveOptions="0"
flag="E"
msg="Selected day is not a working day"
Goto POPUP
End If
'/////HALF-Day Leave. //////////////////
%REM
If doc.Leave_Type(0)="Annual Leave (AM)" Or doc.Leave_Type(0)="Annual Leave (PM)" Then
Ndays=0.5
End If
If doc.Leave_Type(0)="Annual Leave (AM)" Or doc.Leave_Type(0)="Annual Leave (PM)" Or doc.Leave_Type(0)="Annual Leave" Then
quota=doc.Tot_Leave(0)
Elseif doc.Leave_Type(0)="Sick Leave" Then
quota=doc.Sick_Leave(0)
End If
%ENDREM
If Cdbl(quota) < Cdbl(Ndays) Then
doc.Submit_Flag="False"
doc.Save_Flag="False"
doc.Emp_CurrStat=doc.Prev_Status(0)
'Print "<br><h2><font color='#FF0000'>You can not apply for "Ndays" day/s of leave, as your leave balance is "quota" day/s.</font></h2>"
'Print"<br><h4> <a href=""JavaScript:history.go(-1)"">Back</a>"
'doc.SaveOptions="0"
flag="E"
msg="You can not apply for "+Cstr(Ndays)+" days of leave, as your leave balance is "+Cstr(quota)+" days."
Goto POPUP
Else
doc.Submit_Flag="True"
doc.Save_Flag="True"
doc.SaveOptions="1"
End If
If (lve_overlap(db,doc.Comp_Fdate(0),doc.Comp_From_ssn(0),doc.Comp_Tdate(0),doc.Comp_To_ssn(0),doc.Comp_EName(0))=1)Then
doc.Submit_Flag="False"
doc.Save_Flag="False"
doc.saveoptions="0"
’ Print “
Leave period overlaps with your earlier Leave applications.
”
’ Print"
<a href=““JavaScript:history.go(-1)””>Back"
flag="E"
msg="Leave period overlaps with your earlier Leave applications."
Goto POPUP
End If
If ((Cstr(doc.Comp_Fdate(0))=Cstr(doc.Comp_Tdate(0)))And(Cstr(doc.Comp_To_ssn(0))=Cstr(doc.Comp_From_ssn(0)))) Then ' only for 1/2 day
Ndays=Ndays-0.5
Elseif ((Cstr(doc.Comp_Fdate(0))<>Cstr(doc.Comp_Tdate(0))) And (Cstr(doc.Comp_From_ssn(0))="PM")And(Cstr(doc.Comp_To_ssn(0))="AM")) Then ' starting & ending days for 1/2 days
Ndays=Ndays-1
Elseif ((Cstr(doc.Comp_Fdate(0))<>Cstr(doc.Comp_Tdate(0)))And(Cstr(doc.Comp_From_ssn(0))="PM")And(Cstr(doc.Comp_To_ssn(0))="PM")) Then ' starting day 1/2 day & ending day full day
Ndays=Ndays-0.5
Elseif ((Cstr(doc.Comp_Fdate(0))<>Cstr(doc.Comp_Tdate(0)))And(Cstr(doc.Comp_From_ssn(0))="AM")And(Cstr(doc.Comp_To_ssn(0))="AM")) Then ' starting day full day & ending day for 1/2 day
Ndays=Ndays-0.5
End If
doc.No_Days=Ndays
%REM
If doc.Tot_Leave(0) < Ndays Then
’ If Cdat(tdate) < Cdat(fdate) Then
Print "<SCRIPT LANGUAGE=JavaScript>"
'Print "alert(""Status changed to in all documents"")"
'Print "myWindow = window.open("", "tinyWindow", 'width=150,height=100') "
Print "document.write(""Welcome to this new window!"")"
'Print "myWindow.document.bgColor="l"ightblue"""
'Print "myWindow.document.close() "
Print "history.go(-1)"
Print "</SCRIPT>"
Exit Sub
End If
%ENDREM
POPUP:
Print "<script>"
Print "window.opener.returnvalue("+Ndays+","""+flag+""","""+msg+""","""+Nhrs+""")"
Print "window.close()"
Print "</script>"
Exit Sub
ErrorHandler:
Print "<BODY BGCOLOR='#FFFFFF'>"
Print "<H3><b>Error : <font color='#FF0000'>Please contact your administrator</font><font color='#000000'>"
Print "Error" + Str(Err) + ": " + Error$+"</b></H3>"
Print "</BODY>"
doc.saveoptions="0"
End Sub
Subject: RE: Object variable not set
Modify your error handler code to display the actual line no causing the error i.e.
replace
ErrorHandler:
Print "<BODY BGCOLOR='#FFFFFF'>"
Print "<H3><b>Error : <font color='#FF0000'>Please contact your administrator</font><font color='#000000'>"
Print "Error" + Str(Err) + ": " + Error$+"</b></H3>"
Print "</BODY>"
doc.saveoptions="0"
with
ErrorHandler:
Print "<BODY BGCOLOR='#FFFFFF'>"
Print "<H3><b>Error : <font color='#FF0000'>Please contact your administrator</font><font color='#000000'>"
Print "Error" + Str(Err) + ": " + Error$+ "at line no : " + Cstr(Erl) + "</b></H3>"
Print "</BODY>"
doc.saveoptions="0"
run the process again and now the error message should include the line number … which would help you to identify the problem.