Object Variable not set

Hi! All,

I am trying to get the value of newly create document through lotus script it return error object variable not set.

What I did I have a from which create document on submit. I used

@do(@command([filesave]);@command([toolsrunmacro];“createdocuemnt”)

I wrote an agent in lotus script where i copy this newly created document to the another database named “user.nsf”

my lotus script is:

dim doc as notesdocument

dim session as new notessession

Set doc=session.DocumentContext

    Dim userDoc As NotesDocument 

Dim userDb As NotesDatabase 

Set userDb = New NotesDatabase("","User.nsf")

Call doc.CopyToDatabase(userDb)	

call doc.save(true,true)

this code copy the current document to user.nsf because when i open the view this document shows the document.

now below this i used additional code:

    Set userDb = New NotesDatabase("","User.nsf")

Dim UserView As NotesView 

Dim newuserDoc As NotesDocument 

Set UserView = userDB.GetView("userRegistration")

UserView.Refresh 

Set newuserDoc = UserView.GetDocumentByKey(doc.emailID(0))

If Not (newuserDoc Is Nothing) Then

	Msgbox "document not found"

Else

	Msgbox "inside"

	Msgbox newuserdoc.UniversalID

	Msgbox newuserdoc.emailID(0)

end if

after executing this code it goes inside the else part and at server console it prompt “inside” so that is clear that it fetch the document sucessfully. but when control goes to next line

msgbox newuserdoc.emailID(0)

or

msgobx newuserdoc.UniversalID

it show message on server consloe

object variable not set.

can any help me please. Where i doing wrong.

Actuallly I want to get the document id of the newly created document.

Please help…

Its an urgent

With Regards,

Vikas K Sinha

Subject: Object Variable not set

Hello Vikas,

Your check is wrong:

if newuserdoc is Nothing then

 Msgbox "document not found"

Else

without the Not

Joost

Subject: Object Variable not set

Subject: Object Variable not set

Hi vikas, u have declared Notes document class but u haven’t set the notes document class.Sometimes u may get the Error because of this also.So just ckeck it and if u didnt get it just feel free to contact me

Subject: RE: Object Variable not set

Thanks All for your response…But i have already set the notes document class

Set newuserDoc = UserView.GetDocumentByKey(doc.emailID(0))

and joost I have already checked if you will see my code.

If Not (newuserDoc Is Nothing) Then

Msgbox “document not found”

else

end if

one more thing i have given Anonymous to Author access to the database “user.nsf”

Is it correct?

With Regards,

Vikas

Subject: RE: Object Variable not set

Vikas,

I see you perform a check, but the check itself is wrong. Just remove the Not and read it.

If newuserDoc is Nothing Then = the document does not exist

negating this gives you the wrong result

Joost

Subject: RE: Object Variable not set

Thanks Joost,

You’r great!

Thanks All of you

With Regards,

Vikas K Sinha