LotusScript help (for a newbie)

Hi folks,

Need some help with a lotusscript problem I have. I am currently writing some code that copies the contents of one document, to a newly created document. I have no trouble copying and pasting text fields by using this:

Call objUIDoc.GotoField(“icDescription”)

Call objUIDoc.SelectAll

Call objUIDoc.Copy

Call objUIDoc2.GotoField(“icDescription”)

Call objUIDoc2.Paste

However, a lot of fields in the form are combo boxes and when I try the copy and paste method, notes returns an error about the command not being found.

Does anyone know how I am able to copy the contents of combo box and paste it successfully into a new form?

Thanks for any help!

[EDIT]

I’ve come across another problem which puzzles me.

I am prompting the user for 2 numbers before the new form is created, and then I am trying to put those 2 numbers into 2 different fields on the new form, my code snippet is:

Dim release As String

Dim increment As String

release = Inputbox(“Please enter a release number for the Re-Apply”,“Enter Release”)

increment = Inputbox(“Please enter an increment number for the Re-Apply”,“Enter Increment”)

Call objUIDoc2.FieldSetText(icIssueRelease, Cstr (release))

Call objUIDoc2.FieldSetText(icIssueReleaseIncrement, Cstr (increment))

However, notes returns an error saying arguement must be a string. I’ve looked at the debugger and both release and increment are classed as string variables with the number the user puts in. There are strings, so why can’t I set the field?

Thanks for any help with anything!

Bryan =@)

[EDIT II]

Arh! This is most frustrating!

Can anyone tell me whats wrong with this:

If (objUIDoc.GotoField(“icState”) = “11”) Then

Do stuff

Else

End If

It wont compile, illegal reference to: GOTOFIELD

=@(

Seriously, if anyone can help with any of the 3 problems, id be forever grateful

Subject: LotusScript help (for a newbie)

Why not just create another form where all the fields have a default field value that points to themselves? Then you can just write some simple code to compose the new form. Make sure it is set to inherit values from selected document. That should do it.

Subject: LotusScript help (for a newbie)

  1. try to use FieldGetText, FieldSetText instaed of goto, select, copy, goto, paste2) are You sure that “icIssueRelease” and “icIssueReleaseIncrement” are both type of string?

  2. uidoc.GotoGield is a subroutine, not a function.

marcin

Subject: Well…

Marcin

strictly speaking you are right of course, IMHO I just just thought it was a rather opaque response to someone who is obviously struggling with simple Lotus Script

Bryan

“Object Variable Not set” means exactly that, you are referring to an object without having assigned a value to it - run the code through the debugger and look at the value for your uidocument

Subject: RE: Well…

Got it!

I had declared:

Set objUIDoc = objWs.CurrentDocument

but it was further down the page.

I’m only the placement student and they’ve got me making huge changes to their databases!

Their sure getting their money’s worth from me!

Thanks folks, really appriciate it, off to look at my last problem.

Subject: RE: Well…

Got them all cracked!

Thanks once again.

Subject: LotusScript help (for a newbie)

  1. If what you want to do is copy “the contents of one document, to a newly created document” you should look at the CopyAllItems method of NotesDocument(see Notes Help)

  2. The fieldname needs to be a string argument

eg

Call objUIDoc2.FieldSetText(“icIssueRelease”, Cstr (release))

  1. Should be

If (objUIDoc.FieldGetText(“icState”) = “11”) Then

Do stuff

Else

End If

Not sure what Marcin is on abuot, gotofield is a Method (not that that is relevant).

Look at the NotesHelp file, all the above is explained clearly

Gert yourself a good book there a few out there…

You will probably find the free redbook R6 Developers’ Handbook

http://publib-b.boulder.ibm.com/redbooks.nsf/RedbookAbstracts/sg246854.html?Open

worth reading

HTH

Subject: RE: LotusScript help (for a newbie)

  1. i said GotoField is a SUB not a FUNCTION so it returns void :wink:

m

Subject: RE: LotusScript help (for a newbie)

Thanks for your help both!

Problem one is cracked.

Need to closely at problem 2

And now the syntax is correct for problem 3 however, I’m getting this error:

“Object variable not set”

and points to my line

If (objUIDoc.FieldGetText(“icState”) = “11”) Then

Sure I just need to play, no doubt if I get stuck I’ll back. Thanks again!

Bryan =@)

Subject: RE: LotusScript help (for a newbie)

variable objUIDoc contains Nothingi see two possibilities:

  1. lack of:

“set objUIDoc=objUIWorkspace.CurrentDocument”

where objUIWorkspace declared as New NotesUIWorkspace

  1. You have written this script not as form code (for example in view action)

marcin